Skip to content
Permalink
Browse files

Merge PR #2644: Add command-line flags for accessing license informat…

…ion for Mumble and Murmur
  • Loading branch information...
mkrautz committed Nov 25, 2016
2 parents 54eab8d + 25cb53d commit 82c27fef2c86b9169c65ac02e1829603ef4537ef
@@ -40,15 +40,15 @@ ($$$)
}


open(my $F, "> ../src/mumble/licenses.h");
open(my $F, "> ../src/licenses.h");
binmode $F; # Ensure consistent file endings across platforms

print $F "/*\n";
print $F " * This file was auto-generated by scripts/mklic.pl\n";
print $F " * DO NOT EDIT IT MANUALLY\n";
print $F " */\n";
print $F "#ifndef MUMBLE_MUMBLE_LICENSES_H_\n";
print $F "#define MUMBLE_MUMBLE_LICENSES_H_\n";
print $F "#ifndef MUMBLE_LICENSES_H_\n";
print $F "#define MUMBLE_LICENSES_H_\n";
print $F "\n";
print $F "#include <QtGlobal>\n";
print $F "\n";
@@ -0,0 +1,50 @@
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "murmur_pch.h"

#include "License.h"

#include "licenses.h"

QString License::license() {
return QString::fromUtf8(licenseMumble);
}

QString License::authors() {
return QString::fromUtf8(authorsMumble);
}

QList<LicenseInfo> License::thirdPartyLicenses() {
QList<LicenseInfo> licenses;
for (int i = 0; !licenses3rdParties[i].isEmpty(); i++) {
const ThirdPartyLicense *tpl = &licenses3rdParties[i];
LicenseInfo li;
li.name = QString::fromUtf8(tpl->name);
li.url = QString::fromUtf8(tpl->url);
li.license = QString::fromUtf8(tpl->license);
licenses << li;
}
return licenses;
}

QString License::printableThirdPartyLicenseInfo() {
QString output;

QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
foreach (LicenseInfo li, thirdPartyLicenses) {
QString header = QString::fromLatin1("%1 (%2)\n").arg(li.name).arg(li.url);
QString headerHorizLine = QString::fromLatin1("-").repeated(header.size()) + QLatin1String("\n");

output.append(headerHorizLine);
output.append(header);
output.append(headerHorizLine);
output.append(QLatin1String("\n"));
output.append(li.license);
output.append(QLatin1String("\n\n"));
}

return output;
}
@@ -0,0 +1,39 @@
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_LICENSE_H_
#define MUMBLE_LICENSE_H_

#include <QString>
#include <QList>

/// LicenseInfo represents license information
/// for a third-party library used by Mumble.
struct LicenseInfo {
/// The name of the third-party library.
QString name;
/// A URL for the website of the third-party library.
QString url;
/// The license text for the third-party library.
QString license;
};

/// The License class contains static helpers for
/// getting Mumble license/author information.
class License {
public:
/// Get the Mumble license text (the LICENSE file)
static QString license();
/// Get the Mumble authors list (the AUTHORS file)
static QString authors();
/// Get a list of license information for Mumble's
/// third-party libraries.
static QList<LicenseInfo> thirdPartyLicenses();
/// Get a human-readable, ready-to-print combination
/// of all of Mumble's third-party license information.
static QString printableThirdPartyLicenseInfo();
};

#endif
@@ -2,8 +2,8 @@
* This file was auto-generated by scripts/mklic.pl
* DO NOT EDIT IT MANUALLY
*/
#ifndef MUMBLE_MUMBLE_LICENSES_H_
#define MUMBLE_MUMBLE_LICENSES_H_
#ifndef MUMBLE_LICENSES_H_
#define MUMBLE_LICENSES_H_

#include <QtGlobal>

@@ -14,8 +14,8 @@ CONFIG += qt thread debug_and_release warn_on
DEFINES *= MUMBLE_VERSION_STRING=$$VERSION
INCLUDEPATH += $$PWD . ../mumble_proto
VPATH += $$PWD
HEADERS *= ACL.h Channel.h CryptState.h Connection.h Group.h HTMLFilter.h User.h Net.h OSInfo.h Timer.h SSL.h Version.h SSLCipherInfo.h SSLCipherInfoTable.h
SOURCES *= ACL.cpp Group.cpp Channel.cpp Connection.cpp HTMLFilter.cpp User.cpp Timer.cpp CryptState.cpp OSInfo.cpp Net.cpp SSL.cpp Version.cpp SSLCipherInfo.cpp
HEADERS *= ACL.h Channel.h CryptState.h Connection.h Group.h HTMLFilter.h User.h Net.h OSInfo.h Timer.h SSL.h Version.h SSLCipherInfo.h SSLCipherInfoTable.h licenses.h License.h
SOURCES *= ACL.cpp Group.cpp Channel.cpp Connection.cpp HTMLFilter.cpp User.cpp Timer.cpp CryptState.cpp OSInfo.cpp Net.cpp SSL.cpp Version.cpp SSLCipherInfo.cpp License.cpp
LIBS *= -lmumble_proto
# Note: Protobuf generates into its own directory so we can mark it as a
# system include folder for unix. Otherwise the generated code creates
@@ -9,42 +9,42 @@

#include "Global.h"
#include "MainWindow.h"
#include "licenses.h"
#include "License.h"

AboutDialog::AboutDialog(QWidget *p) : QDialog(p) {
setWindowTitle(tr("About Mumble"));

QTabWidget *qtwTab = new QTabWidget(this);
QVBoxLayout *vblMain = new QVBoxLayout(this);

QTextEdit *qteLicense=new QTextEdit(qtwTab);
QTextEdit *qteLicense = new QTextEdit(qtwTab);
qteLicense->setReadOnly(true);
qteLicense->setPlainText(QLatin1String(licenseMumble));
qteLicense->setPlainText(License::license());

QTextEdit *qteAuthors = new QTextEdit(qtwTab);
qteAuthors->setReadOnly(true);
qteAuthors->setPlainText(QString::fromUtf8(authorsMumble));
qteAuthors->setPlainText(License::authors());

QTextBrowser *qtb3rdPartyLicense = new QTextBrowser(qtwTab);
qtb3rdPartyLicense->setReadOnly(true);
qtb3rdPartyLicense->setOpenExternalLinks(true);

for(int i = 0; !licenses3rdParties[i].isEmpty(); ++i)
{
QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
foreach(LicenseInfo li, thirdPartyLicenses) {
qtb3rdPartyLicense->append(QString::fromLatin1("<h3>%1 (<a href=\"%2\">%2</a>)</h3><pre>%3</pre>")
.arg(Qt::escape(QString::fromLatin1(licenses3rdParties[i].name)))
.arg(Qt::escape(QString::fromLatin1(licenses3rdParties[i].url)))
.arg(Qt::escape(QString::fromLatin1(licenses3rdParties[i].license))));
.arg(Qt::escape(li.name))
.arg(Qt::escape(li.url))
.arg(Qt::escape(li.license)));
}

qtb3rdPartyLicense->moveCursor(QTextCursor::Start);

QWidget *about=new QWidget(qtwTab);
QWidget *about = new QWidget(qtwTab);

QLabel *icon=new QLabel(about);
QLabel *icon = new QLabel(about);
icon->setPixmap(g.mw->qiIcon.pixmap(g.mw->qiIcon.actualSize(QSize(128, 128))));

QLabel *text=new QLabel(about);
QLabel *text = new QLabel(about);
text->setOpenExternalLinks(true);
text->setText(tr(
"<h3>Mumble (%1)</h3>"
@@ -54,7 +54,7 @@ AboutDialog::AboutDialog(QWidget *p) : QDialog(p) {
).arg(QLatin1String(MUMBLE_RELEASE))
.arg(QLatin1String("http://www.mumble.info/"))
.arg(QLatin1String("Copyright 2005-2016 The Mumble Developers")));
QHBoxLayout *qhbl=new QHBoxLayout(about);
QHBoxLayout *qhbl = new QHBoxLayout(about);
qhbl->addWidget(icon);
qhbl->addWidget(text);

@@ -35,6 +35,7 @@
#include "ApplicationPalette.h"
#include "Themes.h"
#include "UserLockFile.h"
#include "License.h"

#if defined(USE_STATIC_QT_PLUGINS) && QT_VERSION < 0x050000
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
@@ -136,6 +137,12 @@ int main(int argc, char **argv) {
" Allow multiple instances of the client to be started.\n"
" -n, --noidentity\n"
" Suppress loading of identity files (i.e., certificates.)\n"
" --license\n"
" Show the Mumble license.\n"
" --authors\n"
" Show the Mumble authors.\n"
" --third-party-licenses\n"
" Show licenses for third-party software used by Mumble.\n"
"\n"
);
QString rpcHelpBanner = MainWindow::tr(
@@ -176,6 +183,15 @@ int main(int argc, char **argv) {
} else if (args.at(i) == QLatin1String("-n") || args.at(i) == QLatin1String("--noidentity")) {
suppressIdentity = true;
g.s.bSuppressIdentity = true;
} else if (args.at(i) == QLatin1String("-license") || args.at(i) == QLatin1String("--license")) {
printf("%s\n", qPrintable(License::license()));
return 0;
} else if (args.at(i) == QLatin1String("-authors") || args.at(i) == QLatin1String("--authors")) {
printf("%s\n", qPrintable(License::authors()));
return 0;
} else if (args.at(i) == QLatin1String("-third-party-licenses") || args.at(i) == QLatin1String("--third-party-licenses")) {
printf("%s", qPrintable(License::printableThirdPartyLicenseInfo()));
return 0;
} else if (args.at(i) == QLatin1String("rpc")) {
bRpcMode = true;
if (args.count() - 1 > i) {
@@ -198,7 +198,7 @@ SOURCES *= BanEditor.cpp \
OverlayPositionableItem.cpp \
widgets/MUComboBox.cpp

DIST *= ../../icons/mumble.ico licenses.h ../../icons/mumble.xpm murmur_pch.h mumble.plist
DIST *= ../../icons/mumble.ico ../../icons/mumble.xpm murmur_pch.h mumble.plist
RESOURCES *= mumble.qrc mumble_translations.qrc mumble_flags.qrc ../../themes/MumbleTheme.qrc
FORMS *= ConfigDialog.ui \
MainWindow.ui \
@@ -0,0 +1,86 @@
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "murmur_pch.h"

#if QT_VERSION >= 0x050000
# include <QtWidgets/QApplication>
#else
# include <QtGui/QApplication>
#endif

#include "About.h"
#include "Version.h"
#include "License.h"

AboutDialog::AboutDialog(QWidget *p, AboutDialogOptions options) : QDialog(p) {
setWindowTitle(tr("About Murmur"));
setMinimumSize(QSize(400, 300));

QTabWidget *qtwTab = new QTabWidget(this);
QVBoxLayout *vblMain = new QVBoxLayout(this);

QTextEdit *qteLicense = new QTextEdit(qtwTab);
qteLicense->setReadOnly(true);
qteLicense->setPlainText(License::license());

QTextEdit *qteAuthors = new QTextEdit(qtwTab);
qteAuthors->setReadOnly(true);
qteAuthors->setPlainText(License::authors());

QTextBrowser *qtb3rdPartyLicense = new QTextBrowser(qtwTab);
qtb3rdPartyLicense->setReadOnly(true);
qtb3rdPartyLicense->setOpenExternalLinks(true);

QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
foreach(LicenseInfo li, thirdPartyLicenses) {
qtb3rdPartyLicense->append(QString::fromLatin1("<h3>%1 (<a href=\"%2\">%2</a>)</h3><pre>%3</pre>")
.arg(Qt::escape(li.name))
.arg(Qt::escape(li.url))
.arg(Qt::escape(li.license)));
}

qtb3rdPartyLicense->moveCursor(QTextCursor::Start);

QWidget *about = new QWidget(qtwTab);

QLabel *icon = new QLabel(about);
QIcon windowIcon = QApplication::windowIcon();
icon->setPixmap(windowIcon.pixmap(windowIcon.actualSize(QSize(128, 128))));

QLabel *text = new QLabel(about);
text->setOpenExternalLinks(true);
text->setText(tr(
"<h3>Murmur (%1)</h3>"
"<p>%3</p>"
"<p><tt><a href=\"%2\">%2</a></tt></p>"
).arg(QLatin1String(MUMBLE_RELEASE))
.arg(QLatin1String("http://www.mumble.info/"))
.arg(QLatin1String("Copyright 2005-2016 The Mumble Developers")));
QHBoxLayout *qhbl = new QHBoxLayout(about);
qhbl->addWidget(icon);
qhbl->addWidget(text);

qtwTab->addTab(about, tr("&About Murmur"));
qtwTab->addTab(qteLicense, tr("&License"));
qtwTab->addTab(qteAuthors, tr("A&uthors"));
qtwTab->addTab(qtb3rdPartyLicense, tr("&Third-party licenses"));

if (options == AboutDialogOptionsShowAbout) {
qtwTab->setCurrentWidget(about);
} else if (options == AboutDialogOptionsShowLicense) {
qtwTab->setCurrentWidget(qteLicense);
} else if (options == AboutDialogOptionsShowAuthors) {
qtwTab->setCurrentWidget(qteAuthors);
} else if (options == AboutDialogOptionsShowThirdPartyLicenses) {
qtwTab->setCurrentWidget(qtb3rdPartyLicense);
}

QPushButton *okButton = new QPushButton(tr("OK"), this);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));

vblMain->addWidget(qtwTab);
vblMain->addWidget(okButton);
}
@@ -0,0 +1,34 @@
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_MURMUR_ABOUT_H_
#define MUMBLE_MURMUR_ABOUT_H_

#include <QtCore/QtGlobal>
#include <QtCore/QObject>
#if QT_VERSION >= 0x050000
# include <QtWidgets/QDialog>
#else
# include <QtGui/QDialog>
#endif

enum AboutDialogOptions {
AboutDialogOptionsShowAbout,
AboutDialogOptionsShowLicense,
AboutDialogOptionsShowAuthors,
AboutDialogOptionsShowThirdPartyLicenses,

AboutDialogOptionsDefault = AboutDialogOptionsShowAbout
};

class AboutDialog : public QDialog {
private:
Q_OBJECT
Q_DISABLE_COPY(AboutDialog)
public:
AboutDialog(QWidget *parent, AboutDialogOptions options = AboutDialogOptionsDefault);
};

#endif

0 comments on commit 82c27fe

Please sign in to comment.
You can’t perform that action at this time.