diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-10-09 21:58:15 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2020-10-13 19:08:55 +0200 |
commit | f8c05f3dee29c7ab1eb3eba82c917fe18333fc41 (patch) | |
tree | 4dc17ad736d670652c8f6f9437afd9a71f4cdada | |
parent | 73d0c7a96df2212d5a3ee6289fc286f3e6459028 (diff) |
[pkg] add vendor icon to app
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | bitmask.pro | 15 | ||||
-rwxr-xr-x | branding/scripts/init | 7 | ||||
-rw-r--r-- | branding/templates/vendor/vendor.qrc | 5 | ||||
-rwxr-xr-x | gui/build.sh | 9 | ||||
-rw-r--r-- | gui/main.cpp | 3 | ||||
-rw-r--r-- | gui/providers/providers.json | 4 | ||||
-rw-r--r-- | gui/qml/AboutDialog.qml | 1 | ||||
-rw-r--r-- | gui/qml/main.qml | 10 | ||||
-rw-r--r-- | pkg/config/logger.go | 10 | ||||
-rw-r--r-- | providers/riseup/vendor.qrc | 5 |
11 files changed, 63 insertions, 20 deletions
@@ -73,18 +73,26 @@ else EXTRA_FLAGS = endif +ifeq ($(PLATFORM), windows) +EXTRA_GO_LDFLAGS = "-H windowsgui" +endif + golib: # TODO stop building golib in gui/build.sh, it's redundant. # we should port the buildGoLib parts of the gui/build.sh script here @echo "doing nothing" -build: golib build_helper build_openvpn - @XBUILD=no TARGET=${TARGET} gui/build.sh +build_gui: + @XBUILD=no TARGET=${TARGET} VENDOR_PATH=${VENDOR_PATH}/${PROVIDER} gui/build.sh + +build: golib build_helper build_openvpn build_gui build_helper: @echo "PLATFORM: ${PLATFORM}" @mkdir -p build/bin/${PLATFORM} - go build -o build/bin/${PLATFORM}/bitmask-helper -ldflags "-X main.AppName=${APPNAME} -X main.Version=${VERSION} -H windowsgui" ./cmd/bitmask-helper/ + + go build -o build/bin/${PLATFORM}/bitmask-helper -ldflags "-X main.AppName=${APPNAME} -X main.Version=${VERSION} ${EXTRA_GO_LDFLAGS}" ./cmd/bitmask-helper/ + @echo "build helper done." build_openvpn: @[ -f $(OPENVPN_BIN) ] && echo "OpenVPN already built at" $(OPENVPN_BIN) || ./branding/thirdparty/openvpn/build_openvpn.sh diff --git a/bitmask.pro b/bitmask.pro index 795a3d5..c22ee8c 100644 --- a/bitmask.pro +++ b/bitmask.pro @@ -6,13 +6,19 @@ unix:DEBUG:CONFIG += debug lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5") QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11 +!defined(VENDOR_PATH, var):VENDOR_PATH="providers/riseup" + +RESOURCES += gui/gui.qrc +RESOURCES += $$VENDOR_PATH/vendor.qrc + +ICON = $$VENDOR_PATH/icon.png + macx { + ICON = $$VENDOR_PATH/assets/icon.icns LIBS += -framework Security - # TODO -- pass the vendor icon here from Makefile. - ICON = branding/assets/riseup/icon.icns } win32 { - RC_ICONS = branding/assets/riseup/icon.ico + RC_ICONS = $$VENDOR_PATH/assets/icon.ico } QT += qml quick widgets @@ -31,9 +37,6 @@ HEADERS += \ # we build from build/qt LIBS += -L../../lib -lgoshim -lpthread -RESOURCES += gui/gui.qrc -RESOURCES += providers/riseup/vendor.qrc - DESTDIR = release OBJECTS_DIR = release/.obj MOC_DIR = release/.moc diff --git a/branding/scripts/init b/branding/scripts/init index 4c57d43..aa22326 100755 --- a/branding/scripts/init +++ b/branding/scripts/init @@ -12,6 +12,7 @@ PROVIDER=None SCRIPT_NAME = sys.argv[0] CA_README = "CERT.Readme" ASSETS_README = "assets/FILES.Readme" +VENDOR_QRC = "vendor.qrc" def initVendor(): global VENDOR_PATH @@ -87,11 +88,15 @@ def initVendorConfig(): with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ASSETS_REQUIRED")) as f: allAssets = f.read() - with open(os.path.join(VENDOR_PATH, ASSETS_README), "w") as f: f.write(ASSETS_INFO) f.write(allAssets) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../templates/vendor/vendor.qrc")) as f: + qrc = f.read() + with open(os.path.join(VENDOR_PATH, VENDOR_QRC), "w") as f: + f.write(qrc) + def initGitRepo(): out = subprocess.run(['git', 'init'], cwd=VENDOR_PATH) if out.returncode != 0: diff --git a/branding/templates/vendor/vendor.qrc b/branding/templates/vendor/vendor.qrc new file mode 100644 index 0000000..2cfa32b --- /dev/null +++ b/branding/templates/vendor/vendor.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/vendor/"> + <file alias="icon.svg">assets/icon.svg</file> + </qresource> +</RCC> diff --git a/gui/build.sh b/gui/build.sh index 8b336fa..deb73a1 100755 --- a/gui/build.sh +++ b/gui/build.sh @@ -1,6 +1,9 @@ #!/bin/bash set -e -set -x + +# DEBUG -------------- +# set -x +# -------------------- XBUILD=${XBUILD-no} OSX_TARGET=10.11 @@ -13,6 +16,7 @@ SOURCE_GOLIB=gui/backend.go QTBUILD=build/qt RELEASE=$QTBUILD/release +VENDOR_PATH=${VENDOR_PATH-providers/riseup} PLATFORM=$(uname -s) LDFLAGS="" @@ -72,8 +76,9 @@ function buildGoLib { function buildQmake { echo "[+] Now building Qml app with Qt qmake" echo "[+] Using qmake in:" $QMAKE + echo "[+] VENDOR_PATH:" $VENDOR_PATH mkdir -p $QTBUILD - $QMAKE -o $QTBUILD/Makefile "CONFIG-=debug CONFIG+=release" $PROJECT + $QMAKE -o $QTBUILD/Makefile "CONFIG-=debug CONFIG+=release VENDOR_PATH=${VENDOR_PATH}" $PROJECT } function renameOutput { diff --git a/gui/main.cpp b/gui/main.cpp index 684b0be..893cb4d 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -152,6 +152,9 @@ int main(int argc, char **argv) { QTranslator translator; translator.load(QLocale(), QLatin1String("main"), QLatin1String("_"), QLatin1String(":/i18n")); app.installTranslator(&translator); + /* set window icon */ + app.setWindowIcon(QIcon(":/vendor/icon.svg")); + QQmlApplicationEngine engine; QQmlContext *ctx = engine.rootContext(); diff --git a/gui/providers/providers.json b/gui/providers/providers.json index 5c9b08b..6f82ba3 100644 --- a/gui/providers/providers.json +++ b/gui/providers/providers.json @@ -15,7 +15,7 @@ "apiURL": "https://api.black.riseup.net/", "geolocationAPI": "https://api.black.riseup.net:9001/json", "caCertString": "-----BEGIN CERTIFICATE-----\nMIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl\ndXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE\nAwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw\nNDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM\nEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv\nb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m\nTP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a\n7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE\nLliFitEzwIegpMqxCIHXFuobGSCWF4N0qLHkq/SYUMoOJ96O3hmPSl1kFDRMtWXY\niw1SEKjUvpyDJpVs3NGxeLCaA7bAWhDY5s5Yb2fA1o8ICAqhowurowJpW7n5ZuLK\n5VNTlNy6nZpkjt1QycYvNycffyPOFm/Q/RKDlvnorJIrihPkyniV3YY5cGgP+Qkx\nHUOT0uLA6LHtzfiyaOqkXwc4b0ZcQD5Vbf6Prd20Ppt6ei0zazkUPwxld3hgyw58\nm/4UIjG3PInWTNf293GngK2Bnz8Qx9e/6TueMSAn/3JBLem56E0WtmbLVjvko+LF\nPM5xA+m0BmuSJtrD1MUCXMhqYTtiOvgLBlUm5zkNxALzG+cXB28k6XikXt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Stamp": "2020-10-09 22:41:19" } ] -} +}
\ No newline at end of file diff --git a/gui/qml/AboutDialog.qml b/gui/qml/AboutDialog.qml index a101ea3..bd3d77e 100644 --- a/gui/qml/AboutDialog.qml +++ b/gui/qml/AboutDialog.qml @@ -5,6 +5,7 @@ MessageDialog { title: qsTr("About") text: getText() informativeText: getVersion() + icon: StandardIcon.Information function getText() { var _name = ctx ? ctx.appName : "vpn" diff --git a/gui/qml/main.qml b/gui/qml/main.qml index ce72fff..dcffcde 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -42,6 +42,9 @@ ApplicationWindow { showInitFailure() } } + if (ctx.donateURL) { + donateItem.visible = true + } } } @@ -98,8 +101,8 @@ ApplicationWindow { allowEmptyPass = shouldAllowEmptyPass() app.visible = true; - show(); - hide(); + //show(); + //hide(); } function toHuman(st) { @@ -251,8 +254,9 @@ ApplicationWindow { } MenuItem { + id: donateItem text: qsTr("Donate...") - visible: ctx && ctx.donateURL + visible: ctx ? ctx.donateURL : false onTriggered: { donate.visible = true } } diff --git a/pkg/config/logger.go b/pkg/config/logger.go index cb78349..cc7a4f6 100644 --- a/pkg/config/logger.go +++ b/pkg/config/logger.go @@ -25,9 +25,13 @@ import ( //ConfigureLogger to write logs into a file as well as the stderr func ConfigureLogger(logPath string) (io.Closer, error) { dir := path.Dir(logPath) - err := os.MkdirAll(dir, 0700) - if err == nil { - log.Println("ERROR: cannot create data dir") + if _, err := os.Stat(dir); err != nil { + if os.IsNotExist(err) { + err := os.MkdirAll(dir, 0700) + if err == nil { + log.Println("ERROR: cannot create data dir") + } + } } logFile, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err == nil { diff --git a/providers/riseup/vendor.qrc b/providers/riseup/vendor.qrc new file mode 100644 index 0000000..2cfa32b --- /dev/null +++ b/providers/riseup/vendor.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/vendor/"> + <file alias="icon.svg">assets/icon.svg</file> + </qresource> +</RCC> |