├── src ├── debian │ ├── compat │ ├── changelog │ ├── control │ └── rules ├── resources │ ├── icons │ │ ├── main.rc │ │ ├── main.ico │ │ ├── send.png │ │ ├── close.png │ │ ├── listen.png │ │ ├── login.png │ │ ├── logout.png │ │ ├── message.png │ │ └── choose-file.png │ ├── avatars.png │ ├── p2pchat-qt.png │ ├── resource.qrc │ └── theme │ │ ├── red.qss │ │ ├── green.qss │ │ ├── black.qss │ │ ├── blue.qss │ │ ├── default.qss │ │ └── pink.qss ├── translations │ ├── eng.qm │ ├── zh-cn.qm │ ├── zh-tw.qm │ ├── eng.ts │ ├── zh-tw.ts │ └── zh-cn.ts ├── p2pchat-qt.desktop ├── tools.h ├── hintwidget.h ├── hintwidget.cpp ├── chatworker.h ├── main.cpp ├── mainwindow.h ├── tools.cpp ├── fileworker.h ├── p2p.pro ├── chatworker.cpp ├── fileworker.cpp ├── mainwindow.ui └── mainwindow.cpp ├── docs ├── zh-cn │ ├── 编译说明.md │ ├── 课设报告目录.pdf │ ├── 课设报告封面.docx │ └── 源代码文件说明.md └── en │ ├── compile-clarification.md │ └── source-code-clarification.md ├── screenshot ├── deepin-en-chat.png ├── Windows_zh-cn_chat.png ├── deepin_en_initial.png ├── Windows_zh-cn_initial.png ├── deepin_en_file_select.png ├── xfce-zh-cn-theme-blue.png ├── xfce-zh-cn-theme-pink.png ├── xfce-zh-cn-theme-red.png ├── xfce-zh-cn-theme-black.png ├── xfce-zh-cn-theme-green.png ├── Windows_zh-cn_file_receive.png ├── Windows_zh-cn_file_select.png ├── deepin_en_invaild_nickname.png ├── deepin_en_listening_port.png ├── Windows_zh-cn_listening_port.png ├── deepin_en_file_select_status.png ├── Windows_zh-cn_invaild_nickname.png ├── deepin_en_transmission_status.png ├── Windows_zh-cn_file_select_status.png ├── deepin_en_file_transmission_complete.png ├── Windows_zh-cn_file_transmission_status.png └── Windows_zh-cn_file_transmission_complete.png ├── .gitignore ├── release ├── 0.4-release-note.md ├── 0.3-release-note.md ├── 0.5-release-note.md ├── 0.2-release-note.md └── 0.1-release-note.md ├── README_zh-cn.md ├── README.md └── LICENSE /src/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /src/resources/icons/main.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "main.ico" -------------------------------------------------------------------------------- /docs/zh-cn/编译说明.md: -------------------------------------------------------------------------------- 1 | ## 编译说明 2 | 3 | 程序使用 Qt 5.8.0 开发,原则上建议使用版本号大于等于 5.8.0 的 Qt 程序编译运行。 -------------------------------------------------------------------------------- /docs/zh-cn/课设报告目录.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/docs/zh-cn/课设报告目录.pdf -------------------------------------------------------------------------------- /docs/zh-cn/课设报告封面.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/docs/zh-cn/课设报告封面.docx -------------------------------------------------------------------------------- /src/translations/eng.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/translations/eng.qm -------------------------------------------------------------------------------- /src/resources/avatars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/avatars.png -------------------------------------------------------------------------------- /src/translations/zh-cn.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/translations/zh-cn.qm -------------------------------------------------------------------------------- /src/translations/zh-tw.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/translations/zh-tw.qm -------------------------------------------------------------------------------- /src/resources/icons/main.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/main.ico -------------------------------------------------------------------------------- /src/resources/icons/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/send.png -------------------------------------------------------------------------------- /src/resources/p2pchat-qt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/p2pchat-qt.png -------------------------------------------------------------------------------- /screenshot/deepin-en-chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin-en-chat.png -------------------------------------------------------------------------------- /src/resources/icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/close.png -------------------------------------------------------------------------------- /src/resources/icons/listen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/listen.png -------------------------------------------------------------------------------- /src/resources/icons/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/login.png -------------------------------------------------------------------------------- /src/resources/icons/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/logout.png -------------------------------------------------------------------------------- /src/resources/icons/message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/message.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_chat.png -------------------------------------------------------------------------------- /screenshot/deepin_en_initial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_initial.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_initial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_initial.png -------------------------------------------------------------------------------- /screenshot/deepin_en_file_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_file_select.png -------------------------------------------------------------------------------- /screenshot/xfce-zh-cn-theme-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/xfce-zh-cn-theme-blue.png -------------------------------------------------------------------------------- /screenshot/xfce-zh-cn-theme-pink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/xfce-zh-cn-theme-pink.png -------------------------------------------------------------------------------- /screenshot/xfce-zh-cn-theme-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/xfce-zh-cn-theme-red.png -------------------------------------------------------------------------------- /src/resources/icons/choose-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/src/resources/icons/choose-file.png -------------------------------------------------------------------------------- /screenshot/xfce-zh-cn-theme-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/xfce-zh-cn-theme-black.png -------------------------------------------------------------------------------- /screenshot/xfce-zh-cn-theme-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/xfce-zh-cn-theme-green.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_file_receive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_file_receive.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_file_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_file_select.png -------------------------------------------------------------------------------- /screenshot/deepin_en_invaild_nickname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_invaild_nickname.png -------------------------------------------------------------------------------- /screenshot/deepin_en_listening_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_listening_port.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_listening_port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_listening_port.png -------------------------------------------------------------------------------- /screenshot/deepin_en_file_select_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_file_select_status.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_invaild_nickname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_invaild_nickname.png -------------------------------------------------------------------------------- /screenshot/deepin_en_transmission_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_transmission_status.png -------------------------------------------------------------------------------- /docs/en/compile-clarification.md: -------------------------------------------------------------------------------- 1 | ## Compile Clarification 2 | 3 | The program is developed in Qt 5.8.0 , we recommend to use Qt whose version >= 5.8.0 -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_file_select_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_file_select_status.png -------------------------------------------------------------------------------- /screenshot/deepin_en_file_transmission_complete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/deepin_en_file_transmission_complete.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_file_transmission_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_file_transmission_status.png -------------------------------------------------------------------------------- /screenshot/Windows_zh-cn_file_transmission_complete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/P2PChat-Qt/master/screenshot/Windows_zh-cn_file_transmission_complete.png -------------------------------------------------------------------------------- /src/p2pchat-qt.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=0.1 3 | Type=Application 4 | Exec=/usr/bin/p2pchat-qt/p2pchat-qt 5 | Name=p2pchat-qt 6 | Name[zh_CN]=局域网聊天 7 | Name[zh_TW]=局域網聊天 8 | Comment=LAN Talk 9 | Comment[zh_CN]=局域网聊天 10 | Comment[zh_CN]=局域網聊天 11 | Icon=p2pchat-qt 12 | Categories=Network;P2P;Chat;Qt; 13 | -------------------------------------------------------------------------------- /src/debian/changelog: -------------------------------------------------------------------------------- 1 | p2pchat-qt (0.5) unstable; urgency=medium 2 | 3 | * add more default theme 4 | 5 | * double click to comfirm the destination IP address 6 | 7 | * show file size in proper unit in selecting file,sending file and receiving file 8 | 9 | * show warnning when file sender is also file receiver 10 | 11 | -- ypingcn <1344632698@qq.com> Wed, 07 Oct 2017 12:02:00 +0800 12 | -------------------------------------------------------------------------------- /src/tools.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOLS_H 2 | #define TOOLS_H 3 | 4 | #include 5 | 6 | class Tools : public QObject 7 | { 8 | public: 9 | Tools(); 10 | 11 | /* --- Tools --- */ 12 | static QString toIPv4(quint32 arg); 13 | static QString getLocalIP(); 14 | static bool vaildNickName(QString name); 15 | static bool getTransformFileSize(qint64 originNumber,float& newNumber,QString& newUnit); 16 | }; 17 | 18 | #endif // TOOLS_H 19 | -------------------------------------------------------------------------------- /src/debian/control: -------------------------------------------------------------------------------- 1 | Source: p2pchat-qt 2 | Section: utils 3 | Priority: optional 4 | Maintainer: ypingcn <1344632698@qq.com> 5 | Build-Depends: debhelper (>=9), qt5-qmake, qt5-default, qtbase5-dev, libqt5svg5-dev 6 | Standards-Version: 3.9.6 7 | Homepage: https://github.com/ypingcn/P2PChat-Qt 8 | 9 | Package: p2pchat-qt 10 | Architecture: amd64 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: P2PChat-Qt 13 | A simple Qt-based demo for LAN (Local Area Network) chat. 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | moc_*.h 24 | qrc_*.cpp 25 | ui_*.h 26 | Makefile* 27 | *build-* 28 | 29 | # QtCreator 30 | 31 | *.autosave 32 | 33 | # QtCtreator Qml 34 | *.qmlproject.user 35 | *.qmlproject.user.* 36 | 37 | # QtCtreator CMake 38 | CMakeLists.txt.user* 39 | 40 | -------------------------------------------------------------------------------- /src/hintwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRORWIDGET_H 2 | #define ERRORWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class hintWidget : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit hintWidget(QWidget *parent = 0); 15 | void setText(QString content); 16 | 17 | private: 18 | QLabel * labText; 19 | QHBoxLayout * mainLayout; 20 | QTimer * closeTimer; 21 | signals: 22 | 23 | public slots: 24 | }; 25 | 26 | #endif // ERRORWIDGET_H 27 | -------------------------------------------------------------------------------- /release/0.4-release-note.md: -------------------------------------------------------------------------------- 1 | ## release note for version 0.4 2 | 3 | - lastest update: 2017-09-05 4 | 5 | > English 6 | 7 | **New feature:** 8 | 9 | add animation for startup and widget resizement 10 | 11 | expand information display zone for visitors 12 | 13 | **Maintenance:** 14 | 15 | optimize code structure 16 | 17 | [download link](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.4) 18 | 19 | > 中文版 20 | 21 | **新特性:** 22 | 23 | 添加启动和窗体修改动画 24 | 25 | 为未登录用户提供更多的信息展示区域 26 | 27 | **维护:** 28 | 29 | 优化代码结构 30 | 31 | [下载地址](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.4) 32 | 33 | -------------------------------------------------------------------------------- /release/0.3-release-note.md: -------------------------------------------------------------------------------- 1 | ## release note for version 0.3 2 | 3 | - lastest update: 2017-08-19 4 | 5 | > English 6 | 7 | ​ **New feature:** 8 | 9 | ​ add Language switch(English,Simplified Chinese and Traditional Chinese) 10 | 11 | ​ add Help bar(explanations for Nick name,Mask and IP args) 12 | 13 | enjoy it~ 14 | 15 | ​ [download link](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.3) 16 | 17 | > 中文版 18 | 19 | ​ **新特性:** 20 | 21 | ​ 增加界面语言切换功能(英文、简体中文、繁体中文) 22 | 23 | ​ 增加帮助功能(解释昵称、登录模式、IP地址参数) 24 | 25 | ​ 欢迎使用~ 26 | 27 | ​ [下载地址](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.3) 28 | 29 | -------------------------------------------------------------------------------- /src/resources/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | theme/default.qss 4 | icons/send.png 5 | icons/choose-file.png 6 | icons/login.png 7 | icons/logout.png 8 | icons/message.png 9 | icons/listen.png 10 | avatars.png 11 | p2pchat-qt.png 12 | theme/black.qss 13 | theme/blue.qss 14 | theme/green.qss 15 | theme/pink.qss 16 | theme/red.qss 17 | 18 | 19 | -------------------------------------------------------------------------------- /release/0.5-release-note.md: -------------------------------------------------------------------------------- 1 | ## release note for version 0.5 2 | 3 | - lastest update: 2017-10-07 4 | 5 | > English 6 | 7 | **New feature:** 8 | 9 | add more default theme 10 | 11 | double click to comfirm the destination IP address 12 | 13 | show file size in proper unit in selecting file,sending file and receiving file 14 | 15 | show warnning when file sender is also file receiver 16 | 17 | [download link](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.5) 18 | 19 | > 中文版 20 | 21 | **新特性:** 22 | 23 | 添加更多的内置主题 24 | 25 | 双击在线用户列表以完成文件传输时的目的地 IP 地址填写 26 | 27 | 在选择文件、发送文件和接收文件时以合适的单位显示文件大小 28 | 29 | 在尝试给自己发送文件时显示相关的警告 30 | 31 | [下载地址](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.5) 32 | 33 | -------------------------------------------------------------------------------- /src/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #export DH_VERBOSE = 1 5 | 6 | 7 | # see FEATURE AREAS in dpkg-buildflags(1) 8 | #export DEB_BUILD_MAINT_OPTIONS = hardening=+all 9 | 10 | # see ENVIRONMENT in dpkg-buildflags(1) 11 | # package maintainers to append CFLAGS 12 | #export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic 13 | # package maintainers to append LDFLAGS 14 | #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed 15 | 16 | 17 | %: 18 | dh $@ 19 | 20 | 21 | # dh_make generated override targets 22 | # This is example for Cmake (See https://bugs.debian.org/641051 ) 23 | #override_dh_auto_configure: 24 | # dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) 25 | 26 | -------------------------------------------------------------------------------- /release/0.2-release-note.md: -------------------------------------------------------------------------------- 1 | ## release note for version 0.2 2 | 3 | - lastest update: 2017-07-23 4 | 5 | > English 6 | 7 | ​ Version 0.2 is still **Alpha version**. 8 | 9 | ​ **New feature:** 10 | 11 | ​ Rename if the same name file exist. 12 | 13 | ​ Adjust default theme and set fixed size for the program. 14 | 15 | ​ The future development work will continue in ```dev``` branch.To a certain extent,the ```master``` branch will be a release branch. 16 | 17 | ​ [download link](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.2) 18 | 19 | > 中文版 20 | 21 | ​ 0.2版依旧是 **Alpha 版**。 22 | 23 | ​ **新特性:** 24 | 25 |  如果同名文件存在则重命名接收文件。 26 | 27 |  调整默认主题大小并固定程序大小。 28 | 29 |  未来的开发工作将在```dev```分支上继续。```master```某种程度上成为发布分支。 30 | 31 | ​ [下载地址](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.2) 32 | 33 | -------------------------------------------------------------------------------- /README_zh-cn.md: -------------------------------------------------------------------------------- 1 | ## P2PChat-Qt 2 | 3 | - 最后更新: 2017-09-05 4 | 5 | ### 概述 6 | 7 | P2PChat-Qt ,这是我计算机网络课程设计的一个 Qt 小程序。 8 | 9 | ### 下载 10 | 11 | 点 [这里](https://github.com/ypingcn/P2PChat-Qt/releases) 获得不同版本的下载程序。 12 | 13 | ### 编译依赖 14 | 15 | ``` sudo apt install g++ qt5-default qt5-qmake``` 16 | 17 | ### 编译方法 18 | 19 | > 方法一 20 | 21 | - ``` bash build.sh ``` (或者是双击```build.sh```文件,这取决于你的系统。) 22 | 23 | 然后输入您的密码静候安装完成。完成后程序会自行启动。 24 | 25 | > 方法二 26 | 27 | - ``` mkdir build ``` 28 | - ``` cd build ``` 29 | - ``` qmake ../src ``` 30 | - ``` make ``` 31 | 32 | ### 运行 33 | 34 | - ``` ./p2pchat-qt ``` 35 | 36 | 37 | ### 文档 38 | 39 | 文档在这个文件夹里  (/docs/zh-cn). 40 | 41 | ```编译说明.md``` 给出了在选择Qt 版本上的建议。 42 | 43 | ```课设报告封面.docx``` 提供了本次课程设计报告的封面。 44 | 45 | ```课设报告目录.pdf``` 提供了本次课程设计报告的目录,以供参考。 46 | 47 | ```源代码文件说明.md``` 介绍了各个文件夹的作用 -------------------------------------------------------------------------------- /release/0.1-release-note.md: -------------------------------------------------------------------------------- 1 | ## release note for version 0.1 2 | 3 | - lastest update: 2017-06-23 4 | 5 | > English 6 | 7 | ​ To some extent,version 0.1 is **Alpha version** ,you may find some bugs in this version.If so,click [here](https://github.com/ypingcn/P2PChat-Qt/issues) to report it.Thanks anyway. 8 | 9 | ​ Linux version package(deb) is only designed for Debian or other distribution based on Debian,such as Ubuntu.Dependence satisfies in deepin because the package is built on deepin 15.4.Dependence error?click [here](https://github.com/ypingcn/P2PChat-Qt/issues) to report. 10 | 11 | ​ Enjoy it~ 12 | 13 | ​ [download link](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.1) 14 | 15 | > 中文版 16 | 17 | ​ 某种程度上讲,0.1版是 **Alpha 版**,程序或多或少有不完善的地方。发现错误请点击[这里](https://github.com/ypingcn/P2PChat-Qt/issues)报告 18 | 19 | ​ Linux 版本的安装包(deb包)是为 Debian 或其他基于Debian 的发行版所设计的,例如 Ubuntu 。依赖能在 deepin 安装完成因为该版本的安装包是在 deepin 15.4 平台上打包的。发现依赖错误请点击[这里](https://github.com/ypingcn/P2PChat-Qt/issues)报告。 20 | 21 | ​ 欢迎使用~ 22 | 23 | ​ [下载地址](https://github.com/ypingcn/P2PChat-Qt/releases/tag/0.1) 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## P2PChat-Qt 2 | 3 | - lastest update: 2017-09-05 4 | 5 | 6 | > other language: [简体中文](README_zh-cn.md) 7 | 8 | 9 | ### Summary 10 | 11 | P2PChat-Qt , a Qt demo for my Computer Network project. 12 | 13 | ### Download 14 | 15 | Get different version download link,click [here](https://github.com/ypingcn/P2PChat-Qt/releases) 16 | 17 | ### Compile Dependency 18 | 19 | ``` sudo apt install g++ qt5-default qt5-qmake``` 20 | 21 | ### Compile Process 22 | 23 | > Method One 24 | 25 | - ``` bash build.sh ``` (or just double click the file,it depends on your system.) 26 | 27 | and then enter your password to continue.The program will start up automatically. 28 | 29 | > Method Two 30 | 31 | - ``` mkdir build ``` 32 | - ``` cd build ``` 33 | - ``` qmake ../src ``` 34 | - ``` make ``` 35 | 36 | ### Run 37 | 38 | - ``` ./p2pchat-qt ``` 39 | 40 | ### Document 41 | 42 | Document available in this folder (/docs/en). 43 | 44 | ```compile-clarification.md ``` will gives you suggestion in choosing Qt version. 45 | 46 | ```source-code-clarification.md``` will giveyou information about different folders. 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/hintwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "hintwidget.h" 2 | 3 | #include 4 | #include 5 | 6 | hintWidget::hintWidget(QWidget *parent) : QWidget(parent) 7 | { 8 | closeTimer = new QTimer(this); 9 | connect(closeTimer,SIGNAL(timeout()),this,SLOT(close())); 10 | 11 | setFixedHeight(32); 12 | 13 | setAutoFillBackground(true); 14 | setObjectName("hintWidget"); 15 | 16 | labText = new QLabel(); 17 | labText->setObjectName("hintContent"); 18 | labText->setAlignment(Qt::AlignCenter); 19 | labText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 20 | 21 | 22 | mainLayout = new QHBoxLayout(); 23 | mainLayout->addWidget(labText); 24 | // mainLayout->setSpacing(5); 25 | mainLayout->setContentsMargins(3,3,5,3); 26 | setLayout(mainLayout); 27 | } 28 | 29 | void hintWidget::setText(QString content) 30 | { 31 | labText->setText(content); 32 | 33 | if( !this->isVisible() ) 34 | { 35 | this->show(); 36 | closeTimer->start(1500); 37 | } 38 | else 39 | { 40 | closeTimer->stop(); 41 | closeTimer->start(1500); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/chatworker.h: -------------------------------------------------------------------------------- 1 | #ifndef CHATWORKER_H 2 | #define CHATWORKER_H 3 | 4 | #include 5 | #include 6 | 7 | class chatWorker : public QObject 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | 13 | explicit chatWorker(QObject *parent = 0); 14 | 15 | enum message_t{MT_CHAT,MT_LOGIN,MT_LOGOUT,MT_INVOLVE,MT_SYSTEM}; //聊天、登录、退出、在线、系统信息 16 | enum status_t{ST_ONLINE,ST_OFFLINE}; 17 | 18 | void setMask(QString mask) { MASK = mask; } 19 | void setStatus(status_t status) { currentStatusType = status; } 20 | void setUserName(QString name) { USER_NAME = name; } 21 | 22 | status_t status() { return currentStatusType; } 23 | 24 | void sendJson(message_t type, QString nick_name, QString content=""); 25 | 26 | private: 27 | 28 | QString MASK; 29 | QString USER_NAME; 30 | 31 | status_t currentStatusType; 32 | 33 | QSet onlineUsersSet; 34 | 35 | QUdpSocket * messageSender,* messageReader; 36 | const qint16 DEFAULT_MESSAGE_PORT = 6108; // 默认信息端口 37 | 38 | signals: 39 | 40 | void messageShowReady(chatWorker::message_t type, QString hint, QString content); 41 | void onlineUsersUpdateReady(QSet set); 42 | 43 | private slots: 44 | 45 | void readAllMessage(); 46 | 47 | }; 48 | 49 | #endif // CHATWORKER_H 50 | -------------------------------------------------------------------------------- /docs/zh-cn/源代码文件说明.md: -------------------------------------------------------------------------------- 1 | | 文件夹 | 作用 | 2 | | ----------------------- | ---------------------- | 3 | | /src | 程序源代码 | 4 | | /screenshot | 程序运行截图 | 5 | | /release | 版本发布日志以及相关下载地址 | 6 | | /src/debian | 程序打包成Linux 平台下的 deb 包用 | 7 | | /src/resources/icons | 程序中的图标文件 | 8 | | /src/resources/theme/ | 程序的默认主题配置文件 | 9 | | /src/translations | 程序显示文字的翻译文件夹 | 10 | | /src/main.cpp | 程序入口 | 11 | | /src/mainwindows.cpp | 主窗体源代码 | 12 | | /src/mainwindows.h | 主窗体头文件,定义了不少的变量与函数 | 13 | | /src/mainwindows.ui | 主窗体用户交互界面生成文件 | 14 | | /src/p2p.pro | Qt 工程文件 | 15 | | /src/tool.cpp | 程序中使用到的工具 | 16 | | /src/tool.h | 程序中使用到的工具 | 17 | | /src/chatworker.cpp | UDP 聊天部分 | 18 | | /src/chatworker.h | UDP 聊天部分 | 19 | | /src/fileworker.cpp | TCP 文件传输部分 | 20 | | /src/fileworker.h | TCP 文件传输部分 | 21 | | /src/hintwidget.cpp | 显示提示信息的窗体 | 22 | | /src/hintwidget.h | 显示提示信息的窗体 | 23 | | /src/p2pchat-qt.desktop | 打包成Linux 平台后的启动方式 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | QApplication a(argc, argv); 11 | 12 | QSettings settings("ypingcn","p2pchat-qt"); 13 | 14 | if(!settings.contains("p2pchat-qt-theme")) 15 | settings.setValue("p2pchat-qt-theme","default"); 16 | 17 | 18 | QFile qss(":/theme/"+settings.value("p2pchat-qt-theme").toString()+".qss"); // 加载主题 19 | if( qss.open(QFile::ReadOnly) ) 20 | qApp->setStyleSheet(qss.readAll()); 21 | qss.close(); 22 | 23 | 24 | if(!settings.contains("p2pchat-qt-lang")) 25 | settings.setValue("p2pchat-qt-lang","zh-cn"); 26 | 27 | QTranslator Translator; // 加载翻译文件 28 | if(QSysInfo::kernelType() == "linux") 29 | Translator.load("/usr/bin/p2pchat-qt/local/"+settings.value("p2pchat-qt-lang").toString()+".qm"); 30 | else 31 | Translator.load(settings.value("p2pchat-qt-lang").toString()+".qm"); 32 | a.installTranslator(&Translator); 33 | 34 | MainWindow w; 35 | w.show(); 36 | w.move(( QApplication::desktop()->width()-w.width() )/2,( QApplication::desktop()->height()-w.height() )/2 ); 37 | 38 | QPropertyAnimation startUp(&w,"windowOpacity"); 39 | startUp.setDuration(400); 40 | startUp.setStartValue(0); 41 | startUp.setEndValue(1); 42 | startUp.setEasingCurve(QEasingCurve::Linear); 43 | startUp.start(); 44 | 45 | return a.exec(); 46 | } 47 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include "tools.h" 5 | #include "fileworker.h" 6 | #include "chatworker.h" 7 | #include "hintwidget.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace Ui { 13 | class MainWindow; 14 | } 15 | 16 | class MainWindow : public QMainWindow 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit MainWindow(QWidget *parent = 0); 22 | ~MainWindow(); 23 | 24 | enum WidgetState{Initial,Add,Remove}; 25 | 26 | fileWorker * file; 27 | chatWorker * chat; 28 | 29 | private: 30 | Ui::MainWindow *ui; 31 | hintWidget * hint; 32 | 33 | void setLocalUserEnable(bool status); // 改变用户登录状态 34 | void setLocalFileEnable(bool status); // 改变文件传输按钮可用性 35 | void setLanguage(void); // 设置界面语言 36 | void setTheme(void); // 设置程序主题 37 | void setWidgetState(WidgetState state); 38 | void getHelp(void);// 帮助界面 39 | 40 | const qint8 DEFAULT_MESSAGE_FONT_SIZE = 14; // 默认信息显示大小 41 | 42 | const QString DEFAULT_FILE_IP = "127.0.0.1"; // 默认文件传输IP地址(内置的地址为演示用) 43 | const quint16 DEFAULT_FILE_PORT = 6109; // 默认文件传输端口 44 | 45 | private slots: 46 | 47 | void showMessage(chatWorker::message_t type,QString hint,QString content); // 将接收到或自身的信息显示到内容框内 48 | void updateProgressBar(fileWorker::update_t type, qint64 number); 49 | void updateOnlineUsers(QSet set); 50 | 51 | void click_btnSendMessage(); 52 | void click_btnLogout(); 53 | void click_btnLogin(); 54 | 55 | void click_btnChooseFile(); 56 | void click_btnListen(); 57 | void click_btnSendFile(); 58 | 59 | void updateFinalIP(QListWidgetItem*); 60 | }; 61 | 62 | #endif // MAINWINDOW_H 63 | -------------------------------------------------------------------------------- /src/resources/theme/red.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(255, 99, 71); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(255, 99, 71); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(255, 99, 71); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 0, 0); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(139, 26, 26); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(255, 99, 71); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(255, 99, 71); 58 | background: rgb(255, 99, 71); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(255, 99, 71, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /src/resources/theme/green.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(67, 205, 128); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(67, 205, 128); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(67, 205, 128); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 0, 0); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(0, 139, 69); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(67, 205, 128); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(67, 205, 128); 58 | background: rgb(67, 205, 128); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(67, 205, 128, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /docs/en/source-code-clarification.md: -------------------------------------------------------------------------------- 1 | | folder | clarification | 2 | | ----------------------- | ---------------------------------------- | 3 | | /src | source code | 4 | | /screenshot | screenshot in different platforms | 5 | | /release | release note and related clarification | 6 | | /src/debian | deb packaging for Linux platform | 7 | | /src/resources/icons | icons in program | 8 | | /src/resources/theme/ | default theme | 9 | | /src/translations | default i18n folder | 10 | | /src/main.cpp | main entry | 11 | | /src/mainwindows.cpp | source code for mainwindow | 12 | | /src/mainwindows.h | header file with variables and functions | 13 | | /src/mainwindows.ui | ui auto-generated file | 14 | | /src/p2p.pro | file for Qt project | 15 | | /src/tool.cpp | tool in mainwindow | 16 | | /src/tool.h | header file for tool | 17 | | /src/chatworker.cpp | UDP chat part | 18 | | /src/chatworker.h | header file for chatworker | 19 | | /src/fileworker.cpp | TCP file transmission part | 20 | | /src/fileworker.h | header file for fileworker | 21 | | /src/hintwidget.cpp | s simple widget for showing hint message | 22 | | /src/hintwidget.h | header file for hintwidget | 23 | | /src/p2pchat-qt.desktop | start-up file for Linux platform | -------------------------------------------------------------------------------- /src/resources/theme/black.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(105, 105, 105); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(105, 105, 105); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(105, 105, 105); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 0, 0); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(0, 0, 0); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(105, 105, 105); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(105, 105, 105); 58 | background: rgb(105, 105, 105); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(105, 105, 105, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /src/resources/theme/blue.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(111, 156, 207); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(111, 156, 207); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(111, 156, 207); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 78, 161); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(0, 78, 161); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(111, 156, 207); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(111, 156, 207); 58 | background: rgb(111, 156, 207); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(111, 156, 207, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /src/resources/theme/default.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(111, 156, 207); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(111, 156, 207); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(111, 156, 207); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 78, 161); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(0, 78, 161); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(111, 156, 207); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(111, 156, 207); 58 | background: rgb(111, 156, 207); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(111, 156, 207, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /src/resources/theme/pink.qss: -------------------------------------------------------------------------------- 1 | QMainWindow,QMessageBox{ 2 | background: rgb(248, 248, 255); 3 | border: none; 4 | } 5 | 6 | QTextBrowser,QListWidget,QLineEdit:enabled,QTextEdit:enabled { 7 | border-radius: 4px; 8 | height: 25px; 9 | border: 1px solid rgb(255, 192, 203); 10 | background: white; 11 | } 12 | 13 | QLineEdit:!enabled,QTextEdit:!enabled{ 14 | border-radius: 4px; 15 | height: 25px; 16 | border: 1px solid rgb(255, 192, 203); 17 | background: rgb(240, 240, 240); 18 | } 19 | 20 | QComboBox { 21 | height: 25px; 22 | min-width: 100px; 23 | border-radius: 4px; 24 | border: 1px solid rgb(255, 192, 203); 25 | background: white; 26 | } 27 | 28 | QComboBox QAbstractItemView { 29 | selection-background-color: white; 30 | selection-color: rgb(0, 0, 0); 31 | } 32 | 33 | QPushButton:enabled { 34 | color: white; 35 | border: none; 36 | background: rgb(255, 105, 180); 37 | height: 25px; 38 | min-width: 70px; 39 | border-radius: 4px; 40 | padding-left: 5px; 41 | padding-right: 5px; 42 | } 43 | 44 | QPushButton:!enabled { 45 | color: white; 46 | border: none; 47 | background: rgb(255, 192, 203); 48 | height: 25px; 49 | min-width: 70px; 50 | border-radius: 4px; 51 | padding-left: 5px; 52 | padding-right: 5px; 53 | } 54 | 55 | QWidget#hintWidget { 56 | border-radius: 4px; 57 | border: 1px solid rgb(255, 192, 203); 58 | background: rgb(255, 192, 203); 59 | } 60 | QLabel#hintContent { 61 | color: white; 62 | background: rgba(255, 192, 203, 80%); 63 | } 64 | -------------------------------------------------------------------------------- /src/tools.cpp: -------------------------------------------------------------------------------- 1 | #include "tools.h" 2 | 3 | #include 4 | #include 5 | 6 | Tools::Tools() 7 | { 8 | 9 | } 10 | 11 | QString Tools::toIPv4(quint32 arg) 12 | { 13 | QString res; 14 | int bits[4],cnt = 0; 15 | while (arg) 16 | { 17 | bits[cnt] = arg % 256; 18 | arg /= 256; 19 | cnt++; 20 | } 21 | for(int i=3;i>=0;i--) 22 | res.append(QString::number(bits[i]).append(i==0?"":".")); 23 | return res; 24 | } 25 | 26 | QString Tools::getLocalIP() 27 | { 28 | QList list = QNetworkInterface::allAddresses(); 29 | foreach(QHostAddress in,list) 30 | { 31 | if(in.protocol() == QAbstractSocket::IPv4Protocol && in.toString().contains("192.168")) 32 | return in.toString(); 33 | } 34 | return QString::null; 35 | } 36 | 37 | bool Tools::vaildNickName(QString name) 38 | { 39 | QRegExp reg1("[A-Za-z0-9_]{1,}"); // 至少有一个大小写字母/数字/下划线 40 | QRegExp reg2("[\u4E00-\u9FA5]{1,}");// 至少有一个中文字符 41 | if(reg1.exactMatch(name)) 42 | return true; 43 | if(reg2.exactMatch(name)) 44 | return true; 45 | return false; 46 | } 47 | 48 | bool Tools::getTransformFileSize(qint64 originNumber,float& newNumber,QString& newUnit) 49 | { 50 | if(originNumber <=0) 51 | return false; 52 | 53 | QString units[7] = { 54 | "Bytes", 55 | "KB", 56 | "MB", 57 | "GB", 58 | "TB", 59 | "EB", 60 | "PB" 61 | }; 62 | 63 | const qint64 RATE = 1000; 64 | qint64 tmp = originNumber; 65 | 66 | int i = 0; 67 | while(tmp > 1000 && i <= 5) 68 | { 69 | i++; 70 | tmp /= RATE; 71 | } 72 | 73 | newUnit = units[i]; 74 | 75 | tmp = 1; 76 | while(i) 77 | { 78 | tmp *= RATE; 79 | i--; 80 | } 81 | newNumber = originNumber * 1.0/ tmp; 82 | return true; 83 | } 84 | -------------------------------------------------------------------------------- /src/fileworker.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEWORKER_H 2 | #define FILEWORKER_H 3 | 4 | #include "chatworker.h" 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class fileWorker : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | 18 | explicit fileWorker(QObject *parent = 0); 19 | 20 | enum listen_t{LT_LISTEN,LT_UNLISTEN}; // 正在监听、未监听 21 | enum update_t{UT_SHOW,UT_HIDE,UT_SETMAX,UT_SETVALUE}; // 更新进度条状态(显示、隐藏、设置最大值、设置当前数值) 22 | 23 | bool startListen(void); 24 | void startSend(void); 25 | void stopWorker(void); 26 | 27 | bool setSendFile(QString path); 28 | void setArgs(QString ip,QString port); 29 | 30 | listen_t status(); 31 | 32 | private: 33 | 34 | listen_t currentListenType; // 程序对于接收端口的监听状态 35 | 36 | QString IP,PORT; 37 | const QString DEFAULT_FILE_STORE = "D:\\"; // 默认保存到D盘(Windows端有效) 38 | 39 | QTcpServer * fileServer; 40 | 41 | /* --- File Send --- */ 42 | QString filePath; // 所要发送的文件路径信息 43 | qint8 sendTimes; // 文件发送次数。第一次尝试连接相应地址,后续发送文件信息 44 | QTcpSocket * sendSocket; // 文件发送socket 45 | QFile * sendFile; // 将要发送的文件 46 | QString sendFileName; // 将要发送的文件名 47 | qint64 sendFileTotalSize,sendFileLeftSize,sendFileEachTransSize; //发送文件总大小、剩余大小、每次传输块大小 48 | QByteArray sendFileBlock; // 每次传输的文件内容 49 | 50 | /* --- File Receive --- */ 51 | QTcpSocket * receiveSocket; // 文件接收socket 52 | QFile * receiveFile; // 接收的文件 53 | QString receiveFileName; // 接受的文件名 54 | qint64 receiveFileTotalSize,receiveFileTransSize; // 接收文件总大小、接收文件已传输大小 55 | QByteArray receiveFileBlock; // 每次接收的文件内容 56 | 57 | signals: 58 | 59 | void messageShowReady(chatWorker::message_t type, QString hint, QString content); 60 | void progressBarUpdateReady(fileWorker::update_t type, qint64 number); 61 | 62 | private slots: 63 | 64 | void acceptConnection(); 65 | void readConnection(); 66 | void sendFileInfo(); 67 | void continueToSend(qint64 size); 68 | }; 69 | 70 | #endif // FILEWORKER_H 71 | -------------------------------------------------------------------------------- /src/p2p.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-05-29T20:23:48 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = p2pchat-qt 12 | TEMPLATE = app 13 | 14 | CONFIG+=c++11 15 | 16 | DEPENDPATH += . 17 | INCLUDEPATH += . 18 | 19 | RC_FILE += resources/icons/main.rc 20 | TRANSLATIONS += translations/eng.ts translations/zh-cn.ts translations/zh-tw.ts 21 | # The following define makes your compiler emit warnings if you use 22 | # any feature of Qt which as been marked as deprecated (the exact warnings 23 | # depend on your compiler). Please consult the documentation of the 24 | # deprecated API in order to know how to port your code away from it. 25 | DEFINES += QT_DEPRECATED_WARNINGS 26 | 27 | # You can also make your code fail to compile if you use deprecated APIs. 28 | # In order to do so, uncomment the following line. 29 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 30 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 31 | 32 | 33 | SOURCES += main.cpp\ 34 | mainwindow.cpp \ 35 | tools.cpp \ 36 | fileworker.cpp \ 37 | chatworker.cpp \ 38 | hintwidget.cpp 39 | 40 | HEADERS += mainwindow.h \ 41 | tools.h \ 42 | fileworker.h \ 43 | chatworker.h \ 44 | hintwidget.h 45 | 46 | FORMS += mainwindow.ui 47 | 48 | RESOURCES += \ 49 | resources/resource.qrc 50 | 51 | DISTFILES += 52 | 53 | icons.files = resources/p2pchat-qt.png 54 | desktop.files = p2pchat-qt.desktop 55 | local.files = translations/*.qm 56 | 57 | isEmpty(INSTALL_PREFIX) { 58 | unix: INSTALL_PREFIX = /usr 59 | else: INSTALL_PREFIX = .. 60 | } 61 | 62 | unix: { 63 | desktop.path = $$INSTALL_PREFIX/share/applications 64 | icons.path = $$INSTALL_PREFIX/share/icons/hicolor/128x128/apps 65 | local.path = $$INSTALL_PREFIX/bin/p2pchat-qt/local 66 | INSTALLS += desktop icons local 67 | } 68 | 69 | target.files = p2pchat-qt 70 | target.path = $$INSTALL_PREFIX/bin/p2pchat-qt 71 | 72 | INSTALLS += target 73 | -------------------------------------------------------------------------------- /src/chatworker.cpp: -------------------------------------------------------------------------------- 1 | #include "chatworker.h" 2 | #include "tools.h" 3 | 4 | #include 5 | #include 6 | 7 | chatWorker::chatWorker(QObject *parent) : QObject(parent) 8 | { 9 | messageSender = new QUdpSocket(); 10 | messageReader = new QUdpSocket(); 11 | 12 | messageReader->bind(DEFAULT_MESSAGE_PORT,QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint ); 13 | connect(messageReader,SIGNAL(readyRead()),this,SLOT(readAllMessage())); 14 | } 15 | 16 | void chatWorker::sendJson(message_t type, QString nick_name, QString content) 17 | { 18 | QJsonObject obj; 19 | 20 | if(nick_name.isEmpty()) 21 | return; 22 | 23 | if(type == MT_CHAT) 24 | obj.insert("type","chat"); 25 | else if(type == MT_LOGIN) 26 | obj.insert("type","login"); 27 | else if(type == MT_LOGOUT) 28 | obj.insert("type","logout"); 29 | else if(type == MT_INVOLVE) 30 | obj.insert("type","involved"); 31 | 32 | 33 | if( !content.isEmpty() ) // content 默认为空 34 | obj.insert("content",content); 35 | 36 | obj.insert("nick-name",nick_name); 37 | 38 | QJsonDocument doc; // json 格式封装将要发送到聊天室内的信息 39 | doc.setObject(obj); 40 | 41 | QByteArray data = doc.toJson(); 42 | 43 | messageSender->writeDatagram(data.data(),data.size(),QHostAddress(MASK),DEFAULT_MESSAGE_PORT); 44 | } 45 | 46 | void chatWorker::readAllMessage() 47 | { 48 | while (messageReader->hasPendingDatagrams()) 49 | { 50 | QByteArray data; 51 | data.resize(messageReader->pendingDatagramSize()); 52 | QHostAddress source; // 信息来源IP 53 | messageReader->readDatagram(data.data(),data.size(),&source); 54 | 55 | QJsonParseError jsonError; 56 | QJsonDocument doc = QJsonDocument::fromJson(data,&jsonError); 57 | if(jsonError.error == QJsonParseError::NoError && doc.isObject()) 58 | { 59 | QJsonObject obj = doc.object(); 60 | if(obj.contains("type") && obj.contains("nick-name")) 61 | { 62 | QJsonValue type = obj.take("type"); // 信息类型 63 | QString info = obj.take("nick-name").toString() + "(" + Tools::toIPv4(source.toIPv4Address()) + ")" ; 64 | if(type.toString() == "chat" && obj.contains("content")) 65 | { 66 | emit messageShowReady(chatWorker::MT_CHAT,info,obj.take("content").toString()); 67 | } 68 | else if(type.toString() == "login") 69 | { 70 | /* --- 查找同名、同IP的用户信息 不存在则添加--- */ 71 | if( !onlineUsersSet.contains(info) ) 72 | onlineUsersSet.insert(info); 73 | if( currentStatusType == ST_ONLINE) // 本地用户在线则向聊天室发送 Involved 信息,交换在线用户信息 74 | sendJson(chatWorker::MT_INVOLVE,USER_NAME); 75 | emit messageShowReady(chatWorker::MT_LOGIN,info,tr(" -- enter the chat room")); 76 | } 77 | else if(type.toString() == "logout") 78 | { 79 | /* --- 查找退出用户信息并从列表删除 --- */ 80 | if(onlineUsersSet.contains(info)) 81 | onlineUsersSet.remove(info); 82 | emit messageShowReady(chatWorker::MT_LOGOUT,info,tr(" -- quit the chat room")); 83 | } 84 | else if(type.toString() == "involved") 85 | { 86 | /* --- 更新在线用户信息 --- */ 87 | if(!onlineUsersSet.contains(info)) 88 | onlineUsersSet.insert(info); 89 | } 90 | } 91 | emit onlineUsersUpdateReady(onlineUsersSet); 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/fileworker.cpp: -------------------------------------------------------------------------------- 1 | #include "fileworker.h" 2 | #include "tools.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | fileWorker::fileWorker(QObject *parent) : QObject(parent) 12 | { 13 | currentListenType = LT_UNLISTEN; 14 | 15 | sendTimes = 0; 16 | 17 | fileServer = new QTcpServer(); 18 | connect(fileServer,SIGNAL(newConnection()),this,SLOT(acceptConnection())); 19 | 20 | sendSocket = new QTcpSocket(); 21 | connect(sendSocket,SIGNAL(connected()),this,SLOT(sendFileInfo())); 22 | connect(sendSocket,SIGNAL(bytesWritten(qint64)),this,SLOT(continueToSend(qint64))); 23 | } 24 | 25 | fileWorker::listen_t fileWorker::status() 26 | { 27 | return currentListenType; 28 | } 29 | 30 | bool fileWorker::startListen() 31 | { 32 | bool status = fileServer->listen(QHostAddress(IP),PORT.toInt()); 33 | 34 | if(status) 35 | currentListenType = LT_LISTEN; 36 | else 37 | currentListenType = LT_UNLISTEN; 38 | 39 | return status; 40 | } 41 | 42 | void fileWorker::stopWorker() 43 | { 44 | fileServer->close(); 45 | currentListenType = LT_UNLISTEN; 46 | } 47 | 48 | bool fileWorker::setSendFile(QString path) 49 | { 50 | if(!path.isEmpty()) 51 | { 52 | sendFile = new QFile(path); 53 | if( sendFile->open(QIODevice::ReadOnly) ) 54 | { 55 | filePath = path; 56 | sendFileName = path.right(path.size()-path.lastIndexOf('/')-1); 57 | 58 | float number; 59 | QString unit; 60 | if( Tools::getTransformFileSize(sendFile->size(),number,unit) ) 61 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Selete: %1 Size: %2 %3").arg(sendFileName,QString::number(number),unit)); 62 | else 63 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Selete: %1").arg(sendFileName)); 64 | 65 | sendTimes = 0; 66 | sendFileBlock.clear(); 67 | return true; 68 | } 69 | else 70 | { 71 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File %1 Read Fail").arg(sendFileName)); 72 | } 73 | } 74 | else 75 | { 76 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- Invaild File Path Info: %1").arg(path)); 77 | } 78 | return false; 79 | } 80 | 81 | void fileWorker::setArgs(QString ip, QString port) 82 | { 83 | IP = ip; 84 | PORT = port; 85 | } 86 | 87 | void fileWorker::acceptConnection() 88 | { 89 | receiveFileTotalSize = receiveFileTransSize = 0; 90 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- New File Arriving")); 91 | 92 | receiveSocket = fileServer->nextPendingConnection(); 93 | connect(receiveSocket,SIGNAL(readyRead()),this,SLOT(readConnection())); 94 | 95 | emit progressBarUpdateReady(UT_SHOW,0); // 显示文件传输进度条 96 | } 97 | 98 | void fileWorker::readConnection() 99 | { 100 | if(receiveFileTotalSize == 0) 101 | { 102 | QDataStream in(receiveSocket); 103 | in>>receiveFileTotalSize>>receiveFileTransSize>>receiveFileName; 104 | 105 | emit progressBarUpdateReady(UT_SETMAX,receiveFileTotalSize); 106 | 107 | QString name = receiveFileName.mid(0,receiveFileName.lastIndexOf(".")); 108 | QString suffix = receiveFileName.mid(receiveFileName.lastIndexOf(".")+1,receiveFileName.size()); 109 | 110 | if( QSysInfo::kernelType() == "linux" ) 111 | { 112 | if(QFile::exists(receiveFileName)) 113 | { 114 | int id = 1; 115 | while( QFile::exists( name + "(" + QString::number(id) + ")." + suffix ) ) 116 | id++; 117 | receiveFile = new QFile( name + "(" + QString::number(id) + ")." + suffix ); 118 | } 119 | else 120 | receiveFile = new QFile(receiveFileName); 121 | } 122 | else 123 | { 124 | if(QFile::exists(DEFAULT_FILE_STORE+receiveFileName)) 125 | { 126 | int id = 1; 127 | while( QFile::exists(DEFAULT_FILE_STORE + name + "(" + QString::number(id) + ")." + suffix) ) 128 | id++; 129 | receiveFile = new QFile(DEFAULT_FILE_STORE + name + "(" + QString::number(id) + ")." + suffix); 130 | } 131 | else 132 | { 133 | receiveFile = new QFile(DEFAULT_FILE_STORE+receiveFileName); // 保存文件 134 | } 135 | } 136 | 137 | receiveFile->open(QFile::ReadWrite); 138 | 139 | float number; 140 | QString unit; 141 | if( Tools::getTransformFileSize(receiveFileTotalSize,number,unit) ) 142 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Arrived: %1 Size: %2 %3").arg(receiveFileName,QString::number(number),unit)); 143 | else 144 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Arrived: %1").arg(receiveFileName)); 145 | } 146 | else 147 | { 148 | receiveFileBlock = receiveSocket->readAll(); 149 | receiveFileTransSize += receiveFileBlock.size(); 150 | 151 | emit progressBarUpdateReady(UT_SETVALUE,receiveFileTransSize); 152 | 153 | receiveFile->write(receiveFileBlock); 154 | receiveFile->flush(); 155 | } 156 | 157 | if(receiveFileTransSize == receiveFileTotalSize) // 文件传输完成 158 | { 159 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Transmission Complete(Receiver)")); 160 | 161 | QMessageBox::StandardButton choice; 162 | choice = QMessageBox::information(nullptr,tr("Open File Folder?"),tr("Open File Folder?"),QMessageBox::Yes,QMessageBox::No); 163 | if(choice == QMessageBox::Yes) 164 | { 165 | if(QSysInfo::kernelType() == "linux") 166 | { 167 | QDir dir(""); 168 | QDesktopServices::openUrl(QUrl(dir.absolutePath() , QUrl::TolerantMode)); // 打开文件夹 169 | } 170 | else 171 | { 172 | QDir dir(DEFAULT_FILE_STORE); 173 | QDesktopServices::openUrl(QUrl(dir.absolutePath() , QUrl::TolerantMode)); // 打开文件夹 174 | } 175 | } 176 | 177 | receiveFileTotalSize = receiveFileTransSize = 0; 178 | receiveFileName = QString::null; 179 | emit progressBarUpdateReady(UT_HIDE,0); 180 | receiveFile->close(); 181 | } 182 | } 183 | 184 | void fileWorker::startSend() 185 | { 186 | if(sendTimes == 0) 187 | { 188 | sendSocket->connectToHost(QHostAddress(IP),PORT.toInt()); 189 | if(!sendSocket->waitForConnected(2000)) // 检测网络情况 190 | QMessageBox::information(nullptr,tr("ERROR"),tr("Network Error"),QMessageBox::Yes); 191 | else 192 | sendTimes = 1; 193 | } 194 | else 195 | sendFileInfo(); 196 | } 197 | 198 | void fileWorker::sendFileInfo() 199 | { 200 | sendFileEachTransSize = 40 * 1024; 201 | 202 | QDataStream out(&sendFileBlock,QIODevice::WriteOnly); 203 | out<size() + sendFileBlock.size(); 206 | sendFileLeftSize = sendFile->size() + sendFileBlock.size(); 207 | 208 | out.device()->seek(0); 209 | out<write(sendFileBlock); 212 | 213 | emit progressBarUpdateReady(UT_SETMAX,sendFileTotalSize); 214 | emit progressBarUpdateReady(UT_SETVALUE,0); 215 | emit progressBarUpdateReady(UT_SHOW,0); 216 | 217 | 218 | float number; 219 | QString unit; 220 | if( Tools::getTransformFileSize(sendFile->size(),number,unit) ) 221 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Send: %1 File Size: %2 %3").arg(sendFileName,QString::number(number),unit)); 222 | else 223 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Send: %1 ").arg(sendFileName)); 224 | } 225 | 226 | void fileWorker::continueToSend(qint64 size) 227 | { 228 | if(sendSocket->state() != QAbstractSocket::ConnectedState) // 网络出错 229 | { 230 | QMessageBox::information(nullptr,tr("ERROR"),tr("Network Error"),QMessageBox::Yes); 231 | emit progressBarUpdateReady(UT_HIDE,0); 232 | return; 233 | } 234 | 235 | sendFileLeftSize -= size; 236 | 237 | if(sendFileLeftSize == 0) // 文件发送完成 238 | { 239 | emit messageShowReady(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Transmission Complete(Sender)")); 240 | 241 | sendSocket->disconnectFromHost(); 242 | 243 | emit progressBarUpdateReady(UT_HIDE,0); 244 | 245 | sendFile->close(); 246 | 247 | sendFile = new QFile(filePath); 248 | sendFile->open(QIODevice::ReadOnly); 249 | sendTimes = 0; 250 | sendFileBlock.clear(); 251 | 252 | } 253 | else 254 | { 255 | sendFileBlock = sendFile->read( qMin(sendFileLeftSize,sendFileEachTransSize) ); 256 | 257 | sendSocket->write(sendFileBlock); 258 | 259 | emit progressBarUpdateReady(UT_SETVALUE,sendFileTotalSize - sendFileLeftSize); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 700 10 | 500 11 | 12 | 13 | 14 | 15 | 700 16 | 500 17 | 18 | 19 | 20 | 21 | 700 22 | 500 23 | 24 | 25 | 26 | Chat 27 | 28 | 29 | 30 | 31 | 32 | 10 33 | 10 34 | 201 35 | 24 36 | 37 | 38 | 39 | 40 | 41 | 42 | NickName: 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 10 59 | 38 60 | 201 61 | 21 62 | 63 | 64 | 65 | 66 | 67 | 68 | Your Address: 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 10 85 | 92 86 | 201 87 | 31 88 | 89 | 90 | 91 | 92 | 93 | 94 | Login 95 | 96 | 97 | 98 | :/icons/login.png:/icons/login.png 99 | 100 | 101 | false 102 | 103 | 104 | 105 | 106 | 107 | 108 | Logout 109 | 110 | 111 | 112 | :/icons/logout.png:/icons/logout.png 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 220 122 | 10 123 | 471 124 | 291 125 | 126 | 127 | 128 | 129 | 130 | 131 | 10 132 | 130 133 | 201 134 | 171 135 | 136 | 137 | 138 | 139 | OnlineUsers: 140 | 141 | 142 | 143 | 144 | 145 | 146 | 10 147 | 310 148 | 201 149 | 31 150 | 151 | 152 | 153 | 154 | 155 | 156 | IP args 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 10 172 | 380 173 | 201 174 | 31 175 | 176 | 177 | 178 | 179 | 180 | 181 | false 182 | 183 | 184 | Send 185 | 186 | 187 | 188 | :/icons/send.png:/icons/send.png 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 10 198 | 420 199 | 201 200 | 23 201 | 202 | 203 | 204 | 0 205 | 206 | 207 | true 208 | 209 | 210 | 211 | 212 | 213 | 220 214 | 310 215 | 471 216 | 101 217 | 218 | 219 | 220 | 221 | 222 | 223 | 220 224 | 420 225 | 471 226 | 26 227 | 228 | 229 | 230 | 231 | 232 | 233 | Qt::Horizontal 234 | 235 | 236 | 237 | 40 238 | 20 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | Send Message 247 | 248 | 249 | 250 | :/icons/message.png:/icons/message.png 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 10 260 | 65 261 | 201 262 | 24 263 | 264 | 265 | 266 | 267 | 268 | 269 | Mask 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 255.255.255.255 278 | 279 | 280 | 281 | 282 | 192.168.255.255 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 10 293 | 350 294 | 201 295 | 26 296 | 297 | 298 | 299 | 300 | 301 | 302 | Listen 303 | 304 | 305 | 306 | :/icons/listen.png:/icons/listen.png 307 | 308 | 309 | 310 | 311 | 312 | 313 | Choose 314 | 315 | 316 | 317 | :/icons/choose-file.png:/icons/choose-file.png 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 0 329 | 0 330 | 700 331 | 19 332 | 333 | 334 | 335 | 336 | Edit 337 | 338 | 339 | 340 | Language 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | Theme 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | Help 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | English 373 | 374 | 375 | 376 | 377 | 简体中文 378 | 379 | 380 | 381 | 382 | 繁體中文 383 | 384 | 385 | 386 | 387 | Help 388 | 389 | 390 | 391 | 392 | About 393 | 394 | 395 | 396 | 397 | Blue 398 | 399 | 400 | 401 | 402 | Black 403 | 404 | 405 | 406 | 407 | Green 408 | 409 | 410 | 411 | 412 | Pink 413 | 414 | 415 | 416 | 417 | Red 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | -------------------------------------------------------------------------------- /src/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | MainWindow::MainWindow(QWidget *parent) : 13 | QMainWindow(parent), 14 | ui(new Ui::MainWindow) 15 | { 16 | ui->setupUi(this); 17 | 18 | hint = new hintWidget(ui->browserMessage); 19 | hint->resize(ui->browserMessage->width(),32); 20 | hint->hide(); 21 | 22 | connect(ui->actionEnglish,&QAction::triggered,this,&MainWindow::setLanguage); 23 | connect(ui->actionSimplifiedChinese,&QAction::triggered,this,&MainWindow::setLanguage); 24 | connect(ui->actionTraditionalChinese,&QAction::triggered,this,&MainWindow::setLanguage); 25 | 26 | connect(ui->actionBlack,&QAction::triggered,this,&MainWindow::setTheme); 27 | connect(ui->actionBlue,&QAction::triggered,this,&MainWindow::setTheme); 28 | connect(ui->actionGreen,&QAction::triggered,this,&MainWindow::setTheme); 29 | connect(ui->actionPink,&QAction::triggered,this,&MainWindow::setTheme); 30 | connect(ui->actionRed,&QAction::triggered,this,&MainWindow::setTheme); 31 | 32 | connect(ui->actionHelp,&QAction::triggered,this,&MainWindow::getHelp); 33 | connect(ui->actionAbout,&QAction::triggered,this,&MainWindow::getHelp); 34 | 35 | connect(ui->btnLogin,SIGNAL(clicked()),this,SLOT(click_btnLogin())); 36 | connect(ui->btnLogout,SIGNAL(clicked(bool)),this,SLOT(click_btnLogout())); 37 | connect(ui->btnListen,SIGNAL(clicked(bool)),this,SLOT(click_btnListen())); 38 | connect(ui->btnSendFile,SIGNAL(clicked(bool)),this,SLOT(click_btnSendFile())); 39 | connect(ui->btnChooseFile,SIGNAL(clicked(bool)),this,SLOT(click_btnChooseFile())); 40 | connect(ui->btnSendMessage,SIGNAL(clicked()),this,SLOT(click_btnSendMessage())); 41 | 42 | connect(ui->listOnlineUser,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(updateFinalIP(QListWidgetItem*))); 43 | 44 | ui->labIPAdress->setText(Tools::getLocalIP()); 45 | ui->edtFinalIP->setText(DEFAULT_FILE_IP); 46 | ui->edtFinalPort->setText(QString::number(DEFAULT_FILE_PORT)); 47 | ui->ProgressBar->hide(); 48 | 49 | setLocalUserEnable(false); 50 | setWidgetState(Initial); 51 | 52 | QFont font; 53 | font.setPixelSize(DEFAULT_MESSAGE_FONT_SIZE); 54 | ui->browserMessage->setFont(font); 55 | 56 | file = new fileWorker; 57 | chat = new chatWorker; 58 | 59 | connect(file,SIGNAL(messageShowReady(chatWorker::message_t,QString,QString)), 60 | this,SLOT(showMessage(chatWorker::message_t,QString,QString)) ); 61 | connect(file,SIGNAL(progressBarUpdateReady(fileWorker::update_t,qint64)), 62 | this,SLOT(updateProgressBar(fileWorker::update_t,qint64)) ); 63 | connect(chat,SIGNAL(messageShowReady(chatWorker::message_t,QString,QString)), 64 | this,SLOT(showMessage(chatWorker::message_t,QString,QString)) ); 65 | connect(chat,SIGNAL(onlineUsersUpdateReady(QSet)), 66 | this,SLOT(updateOnlineUsers(QSet)) ); 67 | } 68 | 69 | MainWindow::~MainWindow() 70 | { 71 | chat->sendJson(chatWorker::MT_LOGOUT,ui->edtName->text()); // 销毁对象前先退出 72 | delete ui; 73 | } 74 | void MainWindow::setLanguage() 75 | { 76 | QSettings settings("ypingcn","p2pchat-qt"); 77 | 78 | if(QObject::sender() == ui->actionEnglish) 79 | settings.setValue("p2pchat-qt-lang","eng"); 80 | else if(QObject::sender() == ui->actionSimplifiedChinese) 81 | settings.setValue("p2pchat-qt-lang","zh-cn"); 82 | else if(QObject::sender() == ui->actionTraditionalChinese) 83 | settings.setValue("p2pchat-qt-lang","zh-tw"); 84 | 85 | hint->setText(tr("Restart the app to switch language")); 86 | } 87 | 88 | void MainWindow::setTheme(void) 89 | { 90 | QSettings settings("ypingcn","p2pchat-qt"); 91 | 92 | QString name; 93 | 94 | if(QObject::sender() == ui->actionBlack) 95 | { 96 | settings.setValue("p2pchat-qt-theme","black"); 97 | name = tr("Black"); 98 | } 99 | else if(QObject::sender() == ui->actionBlue) 100 | { 101 | settings.setValue("p2pchat-qt-theme","blue"); 102 | name = tr("Blue"); 103 | } 104 | else if(QObject::sender() == ui->actionGreen) 105 | { 106 | settings.setValue("p2pchat-qt-theme","green"); 107 | name = tr("Green"); 108 | } 109 | else if(QObject::sender() == ui->actionPink) 110 | { 111 | settings.setValue("p2pchat-qt-theme","pink"); 112 | name = tr("Pink"); 113 | } 114 | else if(QObject::sender() == ui->actionRed) 115 | { 116 | settings.setValue("p2pchat-qt-theme","red"); 117 | name = tr("Red"); 118 | } 119 | 120 | hint->setText(tr("Restart the app to switch to theme: %1").arg(name)); 121 | } 122 | 123 | void MainWindow::getHelp() 124 | { 125 | QDialog * help = new QDialog(this); 126 | QGridLayout * helpLayout = new QGridLayout(help); 127 | 128 | QPixmap pic_avatar(":avatars.png"); 129 | QPixmap pic_icon(":p2pchat-qt.png"); 130 | QLabel * avatar = new QLabel(); 131 | QLabel * icon = new QLabel(); 132 | avatar->setPixmap(pic_avatar); 133 | icon->setPixmap(pic_icon); 134 | 135 | if(QObject::sender() == ui->actionAbout) 136 | { 137 | help->setWindowTitle(tr("About")); 138 | help->resize(600,300); 139 | QTextBrowser * content = new QTextBrowser(); 140 | content->setOpenExternalLinks(true); 141 | 142 | content->append(tr("A simple program designed for LAN chat.")); 143 | content->append(tr("\nFunction:")); 144 | content->append(tr("1. send text message in LAN")); 145 | content->append(tr("2. send file in LAN")); 146 | content->append(tr("\nYou can switch language or get more help from menubar.")); 147 | content->append(tr(" %1 ").arg(tr("click to know more."))); 148 | content->append(tr("\nThe program is licensed under version 3 of the GNU General Public License.")); 149 | content->append(tr("Copyright 2017 ypingcn")); 150 | 151 | 152 | helpLayout->addWidget(avatar,0,0,1,1); 153 | helpLayout->addWidget(icon,1,0,1,1); 154 | helpLayout->addWidget(content,0,1,2,1); 155 | } 156 | else if(QObject::sender() == ui->actionHelp) 157 | { 158 | help->setWindowTitle(tr("Help")); 159 | help->resize(600,450); 160 | 161 | QTextBrowser * content = new QTextBrowser(); 162 | content->setOpenExternalLinks(true); 163 | 164 | content->append(tr("P2PChat-Qt Help")); 165 | content->append(tr("\n --- Nick Name Help")); 166 | content->append(tr("Valid character include : numbers , alphabet ( lower-case and upper-case ) , underline and simplified chinese character.")); 167 | content->append(tr("\n --- Mask Help")); 168 | content->append(tr("Mask help you to chat in different range.")); 169 | content->append(tr("#255.255.255.255 option# local usage , Presentation mode")); 170 | content->append(tr("#192.168.1.1 option# LAN usage , if two clients whose IP begins with 192.168 , are in the same LAN")); 171 | content->append(tr("\n --- IP Args Help")); 172 | content->append(tr("two number mean IP address and port number.")); 173 | content->append(tr("You should input an vaild IP address in the first blank ( four numbers, separated by dots and ranged between 0 and 255 )")); 174 | content->append(tr("#127.0.0.1 is Presentation mode, you should input the destination IP instead.( As OnlineUsers shows )")); 175 | content->append(tr("Number in the second blank should be a number ranged between 1 and 65535")); 176 | content->append(tr("Port number don't recommand to change unless the two clients use the same port for file transmisson.")); 177 | content->append(tr("\n --- Button Help")); 178 | content->append(tr("'Listen' means I am ready to get the file.")); 179 | content->append(tr("'Choose' means to select a file to send to other user.")); 180 | content->append(tr("'Send' means begin to send file.if configuration wrong or bad network,you will see a hint.")); 181 | 182 | helpLayout->addWidget(avatar,0,0,1,1); 183 | helpLayout->addWidget(icon,1,0,1,1); 184 | helpLayout->addWidget(content,0,1,2,1); 185 | } 186 | 187 | help->exec(); 188 | 189 | } 190 | 191 | void MainWindow::showMessage(chatWorker::message_t type, QString hint, QString content) 192 | { 193 | QDateTime now = QDateTime::currentDateTime(); 194 | if(type == chatWorker::MT_LOGIN || type == chatWorker::MT_LOGOUT || type == chatWorker::MT_SYSTEM) 195 | { 196 | ui->browserMessage->setTextColor(QColor(190,190,190)); 197 | ui->browserMessage->append(hint + now.toString(" hh:mm:ss")); 198 | ui->browserMessage->append(content); 199 | } 200 | else if(type == chatWorker::MT_CHAT) 201 | { 202 | ui->browserMessage->setTextColor(QColor(70,130,180)); 203 | ui->browserMessage->append(hint + now.toString(" hh:mm:ss")); 204 | ui->browserMessage->setTextColor(QColor(0,0,0)); 205 | ui->browserMessage->append(content); 206 | } 207 | } 208 | 209 | void MainWindow::updateProgressBar(fileWorker::update_t type,qint64 number) 210 | { 211 | if(type == fileWorker::UT_SHOW) 212 | ui->ProgressBar->show(); 213 | else if(type == fileWorker::UT_HIDE) 214 | ui->ProgressBar->hide(); 215 | else if(type == fileWorker::UT_SETVALUE) 216 | ui->ProgressBar->setValue(number); 217 | else if(type == fileWorker::UT_SETMAX) 218 | ui->ProgressBar->setMaximum(number); 219 | } 220 | 221 | void MainWindow::updateOnlineUsers(QSet set) 222 | { 223 | ui->listOnlineUser->clear(); 224 | ui->listOnlineUser->insertItem(0,tr("Online Users:")); 225 | int i = 1; 226 | for(auto it = set.begin();it!= set.end() ;it++) 227 | ui->listOnlineUser->insertItem(i++,*it); 228 | } 229 | 230 | void MainWindow::setLocalUserEnable(bool status) 231 | { 232 | /* --- 根据用户状态设置按钮可用性 ---*/ 233 | ui->edtName->setEnabled(!status); 234 | ui->edtMessage->setEnabled(status); 235 | ui->btnSendMessage->setEnabled(status); 236 | ui->btnLogin->setEnabled(!status); 237 | ui->btnLogout->setEnabled(status); 238 | ui->boxMask->setEnabled(!status); 239 | } 240 | 241 | void MainWindow::setWidgetState(WidgetState state) 242 | { 243 | QPropertyAnimation * left = new QPropertyAnimation(ui->listOnlineUser,"size"); 244 | QPropertyAnimation * right = new QPropertyAnimation(ui->browserMessage,"size"); 245 | left->setDuration(200); 246 | right->setDuration(200); 247 | left->setEasingCurve(QEasingCurve::OutQuart); 248 | right->setEasingCurve(QEasingCurve::OutQuart); 249 | 250 | if(state == Add) 251 | { 252 | left->setStartValue(QSize(ui->listOnlineUser->width(),ui->listOnlineUser->height())); 253 | left->setEndValue(QSize(ui->listOnlineUser->width(),ui->listOnlineUser->height()-140)); 254 | right->setStartValue(QSize(ui->browserMessage->width(),ui->browserMessage->height())); 255 | right->setEndValue(QSize(ui->browserMessage->width(),ui->browserMessage->height()-140)); 256 | 257 | left->start(); 258 | right->start(); 259 | 260 | ui->labFinalIP->show(); 261 | ui->edtFinalIP->show(); 262 | ui->edtFinalPort->show(); 263 | ui->btnListen->show(); 264 | ui->btnChooseFile->show(); 265 | ui->btnSendFile->show(); 266 | ui->edtMessage->show(); 267 | ui->btnSendMessage->show(); 268 | } 269 | else if(state == Remove || state == Initial) 270 | { 271 | left->setStartValue(QSize(ui->listOnlineUser->width(),ui->listOnlineUser->height())); 272 | left->setEndValue(QSize(ui->listOnlineUser->width(),ui->listOnlineUser->height()+140)); 273 | right->setStartValue(QSize(ui->browserMessage->width(),ui->browserMessage->height())); 274 | right->setEndValue(QSize(ui->browserMessage->width(),ui->browserMessage->height()+140)); 275 | 276 | left->start(); 277 | right->start(); 278 | 279 | ui->labFinalIP->hide(); 280 | ui->edtFinalIP->hide(); 281 | ui->edtFinalPort->hide(); 282 | ui->btnListen->hide(); 283 | ui->btnChooseFile->hide(); 284 | ui->btnSendFile->hide(); 285 | ui->edtMessage->hide(); 286 | ui->btnSendMessage->hide(); 287 | } 288 | } 289 | 290 | void MainWindow::click_btnSendMessage() 291 | { 292 | if(ui->edtMessage->toPlainText().isEmpty()) 293 | { 294 | hint->setText(tr("No message")); 295 | } 296 | else 297 | { 298 | chat->setMask(ui->boxMask->currentText()); 299 | chat->sendJson(chatWorker::MT_CHAT,ui->edtName->text(),ui->edtMessage->toPlainText()); 300 | ui->edtMessage->clear(); 301 | } 302 | } 303 | 304 | void MainWindow::click_btnLogin() 305 | { 306 | if(!Tools::vaildNickName(ui->edtName->text())) 307 | { 308 | hint->setText(tr("Invaild Nickname!")); 309 | } 310 | else if(Tools::getLocalIP() == QString::null) 311 | { 312 | hint->setText(tr("Check your Network to login")); 313 | } 314 | else 315 | { 316 | setLocalUserEnable(true); 317 | setWidgetState(Add); 318 | ui->btnListen->setEnabled(true); 319 | ui->labIPAdress->setText(Tools::getLocalIP()); 320 | chat->setMask(ui->boxMask->currentText()); 321 | chat->sendJson(chatWorker::MT_LOGIN,ui->edtName->text()); 322 | chat->setStatus(chatWorker::ST_OFFLINE); 323 | chat->setUserName(ui->edtName->text()); 324 | } 325 | } 326 | 327 | void MainWindow::click_btnLogout() 328 | { 329 | if(Tools::getLocalIP() == QString::null) 330 | { 331 | hint->setText(tr("Check your Network to logout")); 332 | } 333 | else 334 | { 335 | setLocalUserEnable(false); 336 | setWidgetState(Remove); 337 | 338 | chat->setMask(ui->boxMask->currentText()); 339 | chat->sendJson(chatWorker::MT_LOGOUT,ui->edtName->text()); 340 | chat->setStatus(chatWorker::ST_OFFLINE); 341 | } 342 | 343 | } 344 | 345 | void MainWindow::click_btnChooseFile() 346 | { 347 | QString path = QFileDialog::getOpenFileName(this, tr("Choose File"), ".", tr("All File(*.*)")); 348 | if(!path.isEmpty()) 349 | { 350 | if( file->setSendFile(path) ) 351 | ui->btnSendFile->setEnabled(true); 352 | } 353 | } 354 | 355 | void MainWindow::click_btnListen() 356 | { 357 | fileWorker::listen_t listenType = file->status(); 358 | 359 | if(listenType == fileWorker::LT_UNLISTEN) 360 | { 361 | file->setArgs(ui->edtFinalIP->text(), ui->edtFinalPort->text()); 362 | if( file->startListen() ) 363 | { 364 | ui->btnListen->setText(tr("UnListen")); 365 | showMessage(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Port Listening")); 366 | } 367 | else 368 | { 369 | showMessage(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Port Listening Fail")); 370 | } 371 | 372 | } 373 | else if(listenType == fileWorker::LT_LISTEN) 374 | { 375 | ui->btnListen->setText(tr("Listen")); 376 | file->stopWorker(); 377 | showMessage(chatWorker::MT_SYSTEM,tr("System"),tr(" -- File Port Listening Closed")); 378 | } 379 | } 380 | 381 | void MainWindow::click_btnSendFile() 382 | { 383 | fileWorker::listen_t listenType = file->status(); 384 | if(listenType == fileWorker::LT_LISTEN && (ui->edtFinalIP->text() == DEFAULT_FILE_IP || ui->edtFinalIP->text() == Tools::getLocalIP())) 385 | { 386 | QMessageBox::StandardButton choice; 387 | choice = QMessageBox::information(this,tr("Warnning"),tr("If continue,you will receive the file from yourself,comfirm?"),QMessageBox::Yes,QMessageBox::No); 388 | if(choice == QMessageBox::Yes) 389 | { 390 | file->setArgs(ui->edtFinalIP->text(),ui->edtFinalPort->text()); 391 | file->startSend(); 392 | } 393 | } 394 | else 395 | { 396 | file->setArgs(ui->edtFinalIP->text(),ui->edtFinalPort->text()); 397 | file->startSend(); 398 | } 399 | 400 | } 401 | 402 | void MainWindow::updateFinalIP(QListWidgetItem * arg) 403 | { 404 | QString text = arg->text(); 405 | QRegularExpression pattern("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"); 406 | QRegularExpressionMatch result = pattern.match(text); 407 | 408 | if(result.hasMatch()) 409 | { 410 | ui->edtFinalIP->setText(result.captured(0)); 411 | hint->setText(tr("Choose Online User: ")+text); 412 | } 413 | else 414 | { 415 | hint->setText(tr("Insignificant information: ")+text); 416 | } 417 | } 418 | -------------------------------------------------------------------------------- /src/translations/eng.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Chat 9 | 10 | 11 | 12 | 13 | NickName: 14 | 15 | 16 | 17 | 18 | Your Address: 19 | 20 | 21 | 22 | 23 | Login 24 | 25 | 26 | 27 | 28 | Logout 29 | 30 | 31 | 32 | 33 | OnlineUsers: 34 | 35 | 36 | 37 | 38 | IP args 39 | 40 | 41 | 42 | 43 | Send 44 | 45 | 46 | 47 | 48 | Send Message 49 | 50 | 51 | 52 | 53 | Mask 54 | 55 | 56 | 57 | 58 | 255.255.255.255 59 | 60 | 61 | 62 | 63 | 192.168.255.255 64 | 65 | 66 | 67 | 68 | 69 | Listen 70 | 71 | 72 | 73 | 74 | Choose 75 | 76 | 77 | 78 | 79 | Edit 80 | 81 | 82 | 83 | 84 | Language 85 | 86 | 87 | 88 | 89 | Theme 90 | 91 | 92 | 93 | 94 | 95 | 96 | Help 97 | 98 | 99 | 100 | 101 | English 102 | 103 | 104 | 105 | 106 | 简体中文 107 | 108 | 109 | 110 | 111 | 繁體中文 112 | 113 | 114 | 115 | 116 | 117 | About 118 | 119 | 120 | 121 | 122 | 123 | Blue 124 | 125 | 126 | 127 | 128 | 129 | Black 130 | 131 | 132 | 133 | 134 | 135 | Green 136 | 137 | 138 | 139 | 140 | 141 | Pink 142 | 143 | 144 | 145 | 146 | 147 | Red 148 | 149 | 150 | 151 | 152 | click to know more. 153 | 154 | 155 | 156 | 157 | A simple program designed for LAN chat. 158 | 159 | 160 | 161 | 162 | Restart the app to switch to theme: %1 163 | 164 | 165 | 166 | 167 | 168 | Function: 169 | 170 | 171 | 172 | 173 | 1. send text message in LAN 174 | 175 | 176 | 177 | 178 | 2. send file in LAN 179 | 180 | 181 | 182 | 183 | 184 | You can switch language or get more help from menubar. 185 | 186 | 187 | 188 | 189 | <a href="https://github.com/ypingcn/P2PChat-Qt"> %1 </a> 190 | 191 | 192 | 193 | 194 | 195 | The program is licensed under version 3 of the GNU General Public License. 196 | 197 | 198 | 199 | 200 | Copyright 2017 ypingcn 201 | 202 | 203 | 204 | 205 | P2PChat-Qt Help 206 | 207 | 208 | 209 | 210 | 211 | --- Nick Name Help 212 | 213 | 214 | 215 | 216 | Valid character include : numbers , alphabet ( lower-case and upper-case ) , underline and simplified chinese character. 217 | 218 | 219 | 220 | 221 | 222 | --- Mask Help 223 | 224 | 225 | 226 | 227 | Mask help you to chat in different range. 228 | 229 | 230 | 231 | 232 | #255.255.255.255 option# local usage , Presentation mode 233 | 234 | 235 | 236 | 237 | #192.168.1.1 option# LAN usage , if two clients whose IP begins with 192.168 , are in the same LAN 238 | 239 | 240 | 241 | 242 | 243 | --- IP Args Help 244 | 245 | 246 | 247 | 248 | two number mean IP address and port number. 249 | 250 | 251 | 252 | 253 | You should input an vaild IP address in the first blank ( four numbers, separated by dots and ranged between 0 and 255 ) 254 | 255 | 256 | 257 | 258 | #127.0.0.1 is Presentation mode, you should input the destination IP instead.( As OnlineUsers shows ) 259 | 260 | 261 | 262 | 263 | Number in the second blank should be a number ranged between 1 and 65535 264 | 265 | 266 | 267 | 268 | Port number don't recommand to change unless the two clients use the same port for file transmisson. 269 | 270 | 271 | 272 | 273 | 274 | --- Button Help 275 | 276 | 277 | 278 | 279 | 'Listen' means I am ready to get the file. 280 | 281 | 282 | 283 | 284 | 'Choose' means to select a file to send to other user. 285 | 286 | 287 | 288 | 289 | 'Send' means begin to send file.if configuration wrong or bad network,you will see a hint. 290 | 291 | 292 | 293 | 294 | Online Users: 295 | 296 | 297 | 298 | 299 | No message 300 | 301 | 302 | 303 | 304 | Invaild Nickname! 305 | 306 | 307 | 308 | 309 | Check your Network to login 310 | 311 | 312 | 313 | 314 | Check your Network to logout 315 | 316 | 317 | 318 | 319 | Choose File 320 | 321 | 322 | 323 | 324 | All File(*.*) 325 | 326 | 327 | 328 | 329 | 330 | 331 | System 332 | 333 | 334 | 335 | 336 | Warnning 337 | 338 | 339 | 340 | 341 | If continue,you will receive the file from yourself,comfirm? 342 | 343 | 344 | 345 | 346 | Choose Online User: 347 | 348 | 349 | 350 | 351 | Insignificant information: 352 | 353 | 354 | 355 | 356 | UnListen 357 | 358 | 359 | 360 | 361 | Restart the app to switch language 362 | 363 | 364 | 365 | 366 | -- File Port Listening 367 | 368 | 369 | 370 | 371 | -- File Port Listening Fail 372 | 373 | 374 | 375 | 376 | -- File Port Listening Closed 377 | 378 | 379 | 380 | 381 | chatWorker 382 | 383 | 384 | -- enter the chat room 385 | 386 | 387 | 388 | 389 | -- quit the chat room 390 | 391 | 392 | 393 | 394 | fileWorker 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | System 408 | 409 | 410 | 411 | 412 | -- File Selete: %1 Size: %2 %3 413 | 414 | 415 | 416 | 417 | -- File Selete: %1 418 | 419 | 420 | 421 | 422 | -- File %1 Read Fail 423 | 424 | 425 | 426 | 427 | -- Invaild File Path Info: %1 428 | 429 | 430 | 431 | 432 | -- New File Arriving 433 | 434 | 435 | 436 | 437 | -- File Arrived: %1 Size: %2 %3 438 | 439 | 440 | 441 | 442 | -- File Arrived: %1 443 | 444 | 445 | 446 | 447 | -- File Transmission Complete(Receiver) 448 | 449 | 450 | 451 | 452 | -- File Send: %1 File Size: %2 %3 453 | 454 | 455 | 456 | 457 | -- File Send: %1 458 | 459 | 460 | 461 | 462 | -- File Transmission Complete(Sender) 463 | 464 | 465 | 466 | 467 | Open File Folder? 468 | 469 | 470 | 471 | 472 | 473 | ERROR 474 | 475 | 476 | 477 | 478 | 479 | Network Error 480 | 481 | 482 | 483 | 484 | -------------------------------------------------------------------------------- /src/translations/zh-tw.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Chat 9 | 聊天 10 | 11 | 12 | 13 | NickName: 14 | 昵稱: 15 | 16 | 17 | 18 | Your Address: 19 | 您的地址: 20 | 21 | 22 | 23 | Login 24 | 登入 25 | 26 | 27 | 28 | Logout 29 | 登出 30 | 31 | 32 | 33 | OnlineUsers: 34 | 在線用戶: 35 | 36 | 37 | 38 | IP args 39 | IP 地址參數 40 | 41 | 42 | 43 | Send 44 | 發送 45 | 46 | 47 | 48 | Send Message 49 | 發送信息 50 | 51 | 52 | 53 | Mask 54 | 登錄模式 55 | 56 | 57 | 58 | 255.255.255.255 59 | 255.255.255.255 60 | 61 | 62 | 63 | 192.168.255.255 64 | 192.168.255.255 65 | 66 | 67 | 68 | 69 | Listen 70 | 監聽 71 | 72 | 73 | 74 | Choose 75 | 選擇 76 | 77 | 78 | 79 | Edit 80 | 編輯 81 | 82 | 83 | 84 | Language 85 | 語言設置 86 | 87 | 88 | 89 | Theme 90 | 主題設置 91 | 92 | 93 | 94 | 95 | 96 | Help 97 | 幫助 98 | 99 | 100 | 101 | English 102 | 103 | 104 | 105 | 106 | 简体中文 107 | 108 | 109 | 110 | 111 | 繁體中文 112 | 113 | 114 | 115 | 116 | 117 | About 118 | 关于 119 | 120 | 121 | 122 | 123 | Blue 124 | 天際藍 125 | 126 | 127 | 128 | 129 | Black 130 | 酷炫黑 131 | 132 | 133 | 134 | 135 | Green 136 | 清新綠 137 | 138 | 139 | 140 | 141 | Pink 142 | 可愛粉 143 | 144 | 145 | 146 | 147 | Red 148 | 熱情紅 149 | 150 | 151 | 152 | Restart the app to switch language 153 | 重啟應用完成語言更改 154 | 155 | 156 | 157 | click to know more. 158 | 點擊這裏了解更多信息。 159 | 160 | 161 | 162 | A simple program designed for LAN chat. 163 | 壹個旨在提供局域網聊天的小工具. 164 | 165 | 166 | 167 | Restart the app to switch to theme: %1 168 | 重啟程序以切換到主題:%1 169 | 170 | 171 | 172 | 173 | Function: 174 | 175 | 功能: 176 | 177 | 178 | 179 | 1. send text message in LAN 180 | 1.局域網內發送文字信息 181 | 182 | 183 | 184 | 2. send file in LAN 185 | 2.局域網內發送文件 186 | 187 | 188 | 189 | 190 | You can switch language or get more help from menubar. 191 | 192 | 在菜單欄裏切換語言或者得到更多的使用幫助。 193 | 194 | 195 | 196 | <a href="https://github.com/ypingcn/P2PChat-Qt"> %1 </a> 197 | <a href="https://github.com/ypingcn/P2PChat-Qt"> 點擊此處了解更多 </a> 198 | 199 | 200 | 201 | 202 | The program is licensed under version 3 of the GNU General Public License. 203 | 204 | 基於 GNU GPLv3 授權程序。 205 | 206 | 207 | 208 | Copyright 2017 ypingcn 209 | Copyright 2017 ypingcn 210 | 211 | 212 | 213 | P2PChat-Qt Help 214 | P2PChat-Qt 幫助 215 | 216 | 217 | 218 | 219 | --- Nick Name Help 220 | 221 | --- 昵稱部分 222 | 223 | 224 | 225 | Valid character include : numbers , alphabet ( lower-case and upper-case ) , underline and simplified chinese character. 226 | 有效字符包括:數字,英文字母(大小寫),下劃線和簡體中文字符。 227 | 228 | 229 | 230 | 231 | --- Mask Help 232 | 233 | --- 登錄模式部分 234 | 235 | 236 | 237 | Mask help you to chat in different range. 238 | 登錄模式使妳能在不同的範圍內聊天。 239 | 240 | 241 | 242 | #255.255.255.255 option# local usage , Presentation mode 243 | #255.255.255.255 選項# 本地使用,演示模式 244 | 245 | 246 | 247 | #192.168.1.1 option# LAN usage , if two clients whose IP begins with 192.168 , are in the same LAN 248 | #192.168.255.255 選項# 局域網用,如果兩個用戶均在同壹個局域網且IP地址均以192.168開頭 249 | 250 | 251 | 252 | 253 | --- IP Args Help 254 | 255 | --- IP地址參數部分 256 | 257 | 258 | 259 | two number mean IP address and port number. 260 | 兩個數字代表著 IP 地址和端口號。 261 | 262 | 263 | 264 | You should input an vaild IP address in the first blank ( four numbers, separated by dots and ranged between 0 and 255 ) 265 | 在第壹個空裏填入壹個有效的 IP 地址(在0到255之間的四個數字且以點分隔開) 266 | 267 | 268 | 269 | #127.0.0.1 is Presentation mode, you should input the destination IP instead.( As OnlineUsers shows ) 270 | #127.0.0.1 是演示模式,你得填入文件傳輸的目的地IP(正如在線用戶列表裏顯示的那樣) 271 | 272 | 273 | 274 | Number in the second blank should be a number ranged between 1 and 65535 275 | 第二個空裏的數字得是在1到65535之間的數字 276 | 277 | 278 | 279 | Port number don't recommand to change unless the two clients use the same port for file transmisson. 280 | 端口號不推薦修改,除非兩個用戶之間使用相同的端口來傳輸文件。 281 | 282 | 283 | 284 | 285 | --- Button Help 286 | 287 | --- 按钮帮助 288 | 289 | 290 | 291 | 'Listen' means I am ready to get the file. 292 | 點擊“監聽”意味著我準備好接受文件了。 293 | 294 | 295 | 296 | 'Choose' means to select a file to send to other user. 297 | '選擇' 意味著去選擇壹個文件來發送給其他用戶。 298 | 299 | 300 | 301 | 'Send' means begin to send file.if configuration wrong or bad network,you will see a hint. 302 | ‘發送’意味著開始發送文件,如果配置出錯或者網絡錯誤,將會提示。 303 | 304 | 305 | 306 | Online Users: 307 | 在線用戶: 308 | 309 | 310 | 311 | Warnning 312 | 警告 313 | 314 | 315 | 316 | If continue,you will receive the file from yourself,comfirm? 317 | 如果繼續,將會收到來自自己發送的文件,確認繼續? 318 | 319 | 320 | 321 | Choose Online User: 322 | 已選擇在線用戶: 323 | 324 | 325 | 326 | Insignificant information: 327 | 無效信息: 328 | 329 | 330 | -- enter the chat room 331 | -- 進入了聊天室 332 | 333 | 334 | -- quit the chat room 335 | -- 退出了聊天室 336 | 337 | 338 | 339 | No message 340 | 無信息 341 | 342 | 343 | 344 | Invaild Nickname! 345 | 無效昵稱! 346 | 347 | 348 | Offline 349 | 離線 350 | 351 | 352 | 353 | Check your Network to login 354 | 檢查您的網路以登入 355 | 356 | 357 | 358 | Check your Network to logout 359 | 檢查您的網路以登出 360 | 361 | 362 | 363 | Choose File 364 | 選擇文件 365 | 366 | 367 | 368 | All File(*.*) 369 | 所有文件(*.*) 370 | 371 | 372 | 373 | 374 | 375 | System 376 | 系统提示 377 | 378 | 379 | -- File Selete: %1 380 | -- 選擇了文件:%1 381 | 382 | 383 | 384 | UnListen 385 | 取消監聽 386 | 387 | 388 | 389 | -- File Port Listening 390 | -- 正在監聽文件傳輸端口 391 | 392 | 393 | 394 | -- File Port Listening Fail 395 | -- 文件監聽出錯 396 | 397 | 398 | 399 | -- File Port Listening Closed 400 | -- 取消監聽文件傳輸端口 401 | 402 | 403 | -- New File Arriving 404 | -- 新文件到達 405 | 406 | 407 | -- File Name: %1 File Size: %2 408 | -- 文件名:%1 文件大小:%2 409 | 410 | 411 | -- File Transmission Complete 412 | -- 文件傳輸完畢 413 | 414 | 415 | Open File Folder? 416 | 打開文件夾? 417 | 418 | 419 | ERROR 420 | 錯誤 421 | 422 | 423 | Network Error 424 | 網路錯誤 425 | 426 | 427 | 428 | chatWorker 429 | 430 | 431 | -- enter the chat room 432 | -- 進入了聊天室 433 | 434 | 435 | 436 | -- quit the chat room 437 | -- 退出了聊天室 438 | 439 | 440 | 441 | fileWorker 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | System 455 | 系统提示 456 | 457 | 458 | 459 | -- File Selete: %1 Size: %2 %3 460 | 已選擇文件:%1 大小:%2 %3 461 | 462 | 463 | 464 | -- File Selete: %1 465 | -- 選擇了文件:%1 466 | 467 | 468 | 469 | -- File %1 Read Fail 470 | -- 文件 %1 讀取失敗 471 | 472 | 473 | 474 | -- Invaild File Path Info: %1 475 | -- 無效路徑信息 %1 476 | 477 | 478 | 479 | -- New File Arriving 480 | -- 新文件到達 481 | 482 | 483 | 484 | -- File Arrived: %1 Size: %2 %3 485 | 文件到達:%1 大小:%2 %3 486 | 487 | 488 | 489 | -- File Arrived: %1 490 | 文件到達:%1 491 | 492 | 493 | 494 | -- File Transmission Complete(Receiver) 495 | 文件傳輸完畢(接收端) 496 | 497 | 498 | 499 | -- File Send: %1 File Size: %2 %3 500 | 發送文件:%1 文件大小: %2 %3 501 | 502 | 503 | 504 | -- File Send: %1 505 | 發送文件:%1 506 | 507 | 508 | 509 | -- File Transmission Complete(Sender) 510 | 文件傳輸完畢(發送端) 511 | 512 | 513 | -- File Name: %1 File Size: %2 514 | -- 文件名:%1 文件大小:%2 515 | 516 | 517 | -- File Transmission Complete 518 | -- 文件傳輸完畢 519 | 520 | 521 | 522 | Open File Folder? 523 | 打開文件夾? 524 | 525 | 526 | 527 | 528 | ERROR 529 | 錯誤 530 | 531 | 532 | 533 | 534 | Network Error 535 | 網路錯誤 536 | 537 | 538 | 539 | -------------------------------------------------------------------------------- /src/translations/zh-cn.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindow 6 | 7 | 8 | Chat 9 | 聊天 10 | 11 | 12 | 13 | NickName: 14 | 昵称: 15 | 16 | 17 | 18 | Your Address: 19 | 您的地址: 20 | 21 | 22 | 23 | Login 24 | 登录 25 | 26 | 27 | 28 | Logout 29 | 退出 30 | 31 | 32 | 33 | OnlineUsers: 34 | 在线用户: 35 | 36 | 37 | 38 | IP args 39 | IP 地址参数 40 | 41 | 42 | 43 | Send 44 | 发送 45 | 46 | 47 | 48 | Send Message 49 | 发送信息 50 | 51 | 52 | 53 | Mask 54 | 登录模式 55 | 56 | 57 | 58 | 255.255.255.255 59 | 255.255.255.255 60 | 61 | 62 | 63 | 192.168.255.255 64 | 192.168.255.255 65 | 66 | 67 | 68 | 69 | Listen 70 | 监听 71 | 72 | 73 | 74 | Choose 75 | 选择 76 | 77 | 78 | 79 | Edit 80 | 编辑 81 | 82 | 83 | 84 | Language 85 | 语言设置 86 | 87 | 88 | 89 | Theme 90 | 主题设置 91 | 92 | 93 | 94 | 95 | 96 | Help 97 | 帮助 98 | 99 | 100 | 101 | English 102 | 103 | 104 | 105 | 106 | 简体中文 107 | 108 | 109 | 110 | 111 | 繁體中文 112 | 113 | 114 | 115 | 116 | 117 | About 118 | 关于 119 | 120 | 121 | 122 | 123 | Blue 124 | 天际蓝 125 | 126 | 127 | 128 | 129 | Black 130 | 酷炫黑 131 | 132 | 133 | 134 | 135 | Green 136 | 清新绿 137 | 138 | 139 | 140 | 141 | Pink 142 | 可爱粉 143 | 144 | 145 | 146 | 147 | Red 148 | 热情红 149 | 150 | 151 | 152 | Restart the app to switch language 153 | 重启应用完成语言更改 154 | 155 | 156 | 157 | click to know more. 158 | 点击这里了解更多信息。 159 | 160 | 161 | 162 | A simple program designed for LAN chat. 163 | 一个旨在提供局域网聊天的小工具. 164 | 165 | 166 | 167 | Restart the app to switch to theme: %1 168 | 重启程序以切换到主题:%1 169 | 170 | 171 | 172 | 173 | Function: 174 | 175 | 功能: 176 | 177 | 178 | 179 | 1. send text message in LAN 180 | 1.局域网内发送文字信息 181 | 182 | 183 | 184 | 2. send file in LAN 185 | 2.局域网内发送文件 186 | 187 | 188 | 189 | 190 | You can switch language or get more help from menubar. 191 | 192 | 在菜单栏里切换语言或者得到更多的使用帮助。 193 | 194 | 195 | 196 | <a href="https://github.com/ypingcn/P2PChat-Qt"> %1 </a> 197 | <a href="https://github.com/ypingcn/P2PChat-Qt"> 点击此处了解更多 </a> 198 | 199 | 200 | 201 | 202 | The program is licensed under version 3 of the GNU General Public License. 203 | 204 | 基于 GNU GPLv3 授权程序。 205 | 206 | 207 | 208 | Copyright 2017 ypingcn 209 | Copyright 2017 ypingcn 210 | 211 | 212 | 213 | P2PChat-Qt Help 214 | P2PChat-Qt 帮助 215 | 216 | 217 | 218 | 219 | --- Nick Name Help 220 | 221 | --- 昵称部分 222 | 223 | 224 | 225 | Valid character include : numbers , alphabet ( lower-case and upper-case ) , underline and simplified chinese character. 226 | 有效字符包括:数字,英文字母(大小写),下划线和简体中文字符。 227 | 228 | 229 | 230 | 231 | --- Mask Help 232 | 233 | --- 登录模式部分 234 | 235 | 236 | 237 | Mask help you to chat in different range. 238 | 登录模式使你能在不同的范围内聊天。 239 | 240 | 241 | 242 | #255.255.255.255 option# local usage , Presentation mode 243 | #255.255.255.255 选项# 本地使用,演示模式 244 | 245 | 246 | 247 | #192.168.1.1 option# LAN usage , if two clients whose IP begins with 192.168 , are in the same LAN 248 | #192.168.255.255 选项# 局域网用,如果两个用户均在同一个局域网且IP地址均以192.168开头 249 | 250 | 251 | 252 | 253 | --- IP Args Help 254 | 255 | --- IP地址参数部分 256 | 257 | 258 | 259 | two number mean IP address and port number. 260 | 两个数字代表着 IP 地址和端口号。 261 | 262 | 263 | 264 | You should input an vaild IP address in the first blank ( four numbers, separated by dots and ranged between 0 and 255 ) 265 | 在第一个空里填入一个有效的 IP 地址(在0到255之间的四个数字且以点分隔开) 266 | 267 | 268 | 269 | #127.0.0.1 is Presentation mode, you should input the destination IP instead.( As OnlineUsers shows ) 270 | #127.0.0.1 是演示模式,你得填入文件传输的目的地IP(正如在线用户列表里显示的那样) 271 | 272 | 273 | 274 | Number in the second blank should be a number ranged between 1 and 65535 275 | 第二个空里的数字得是在1到65535之间的数字 276 | 277 | 278 | 279 | Port number don't recommand to change unless the two clients use the same port for file transmisson. 280 | 端口号不推荐修改,除非两个用户之间使用相同的端口来传输文件。 281 | 282 | 283 | 284 | 285 | --- Button Help 286 | 287 | --- 按钮帮助 288 | 289 | 290 | 291 | 'Listen' means I am ready to get the file. 292 | 点击“监听”意味着我准备好接受文件了。 293 | 294 | 295 | 296 | 'Choose' means to select a file to send to other user. 297 | '选择' 意味着去选择一个文件来发送给其他用户。 298 | 299 | 300 | 301 | 'Send' means begin to send file.if configuration wrong or bad network,you will see a hint. 302 | ‘发送’意味着开始发送文件,如果配置出错或者网络错误,将会提示。 303 | 304 | 305 | 306 | Online Users: 307 | 在线用户: 308 | 309 | 310 | 311 | Warnning 312 | 警告 313 | 314 | 315 | 316 | If continue,you will receive the file from yourself,comfirm? 317 | 如果继续,将会收到来自自己发送的文件,确认继续? 318 | 319 | 320 | 321 | Choose Online User: 322 | 已选择在线用户: 323 | 324 | 325 | 326 | Insignificant information: 327 | 无效信息: 328 | 329 | 330 | -- enter the chat room 331 | -- 进入了聊天室 332 | 333 | 334 | -- quit the chat room 335 | -- 退出了聊天室 336 | 337 | 338 | 339 | No message 340 | 无信息 341 | 342 | 343 | 344 | Invaild Nickname! 345 | 无效昵称! 346 | 347 | 348 | Offline 349 | 离线 350 | 351 | 352 | 353 | Check your Network to login 354 | 检查您的网络以登录 355 | 356 | 357 | 358 | Check your Network to logout 359 | 检查您的网络以退出 360 | 361 | 362 | 363 | Choose File 364 | 选择文件 365 | 366 | 367 | 368 | All File(*.*) 369 | 所有文件(*.*) 370 | 371 | 372 | 373 | 374 | 375 | System 376 | 系统提示 377 | 378 | 379 | -- File Selete: %1 380 | -- 选择了文件:%1 381 | 382 | 383 | 384 | UnListen 385 | 取消监听 386 | 387 | 388 | 389 | -- File Port Listening 390 | -- 正在监听文件传输端口 391 | 392 | 393 | 394 | -- File Port Listening Fail 395 | -- 文件监听出错 396 | 397 | 398 | 399 | -- File Port Listening Closed 400 | -- 取消监听文件传输端口 401 | 402 | 403 | -- New File Arriving 404 | -- 新文件到达 405 | 406 | 407 | -- File Name: %1 File Size: %2 408 | -- 文件名:%1 文件大小:%2 409 | 410 | 411 | -- File Transmission Complete 412 | -- 文件传输完毕 413 | 414 | 415 | Open File Folder? 416 | 打开文件夹? 417 | 418 | 419 | ERROR 420 | 错误 421 | 422 | 423 | Network Error 424 | 网络错误 425 | 426 | 427 | 428 | chatWorker 429 | 430 | 431 | -- enter the chat room 432 | -- 进入了聊天室 433 | 434 | 435 | 436 | -- quit the chat room 437 | -- 退出了聊天室 438 | 439 | 440 | 441 | fileWorker 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | System 455 | 系统提示 456 | 457 | 458 | 459 | -- File Selete: %1 Size: %2 %3 460 | 已选择文件:%1 大小:%2 %3 461 | 462 | 463 | 464 | -- File Selete: %1 465 | -- 选择了文件:%1 466 | 467 | 468 | 469 | -- File %1 Read Fail 470 | -- 文件 %1 读取失败 471 | 472 | 473 | 474 | -- Invaild File Path Info: %1 475 | -- 无效路径信息 %1 476 | 477 | 478 | 479 | -- New File Arriving 480 | -- 新文件到达 481 | 482 | 483 | 484 | -- File Arrived: %1 Size: %2 %3 485 | 文件到达:%1 大小:%2 %3 486 | 487 | 488 | 489 | -- File Arrived: %1 490 | 文件到达:%1 491 | 492 | 493 | 494 | -- File Transmission Complete(Receiver) 495 | 文件传输完毕(接收端) 496 | 497 | 498 | 499 | -- File Send: %1 File Size: %2 %3 500 | 发送文件:%1 文件大小: %2 %3 501 | 502 | 503 | 504 | -- File Send: %1 505 | 发送文件:%1 506 | 507 | 508 | 509 | -- File Transmission Complete(Sender) 510 | 文件传输完毕(发送端) 511 | 512 | 513 | -- File Name: %1 File Size: %2 514 | -- 文件名:%1 文件大小:%2 515 | 516 | 517 | -- File Transmission Complete 518 | -- 文件传输完毕 519 | 520 | 521 | 522 | Open File Folder? 523 | 打开文件夹? 524 | 525 | 526 | 527 | 528 | ERROR 529 | 错误 530 | 531 | 532 | 533 | 534 | Network Error 535 | 网络错误 536 | 537 | 538 | 539 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------