[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-mybackup.git</param>
<param name="branch">master</param>
- <param name="revision">dacbcd3</param>
+ <param name="revision">3750615</param>
</service>
-</services>
+</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/LICENSE
^
|
@@ -1,5 +1,5 @@
-Copyright (C) 2020-2021 Jolla Ltd.
-Copyright (C) 2020-2021 Slava Monich <slava@monich.com>
+Copyright (C) 2020-2022 Jolla Ltd.
+Copyright (C) 2020-2022 Slava Monich <slava@monich.com>
You may use this file under the terms of the BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/harbour-lib.pro
^
|
@@ -24,14 +24,18 @@
SOURCES += \
src/HarbourBase32.cpp \
+ src/HarbourBase45.cpp \
src/HarbourClipboard.cpp \
+ src/HarbourColorEditorModel.cpp \
src/HarbourDisplayBlanking.cpp \
src/HarbourJson.cpp \
src/HarbourLib.cpp \
src/HarbourMce.cpp \
src/HarbourMediaPlugin.cpp \
+ src/HarbourObject.cpp \
src/HarbourOrganizeListModel.cpp \
src/HarbourPolicyPlugin.cpp \
+ src/HarbourProcessState.cpp \
src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSingleImageProvider.cpp \
@@ -54,14 +58,18 @@
INCLUDEPATH += include
PUBLIC_HEADERS += \
include/HarbourBase32.h \
+ include/HarbourBase45.h \
include/HarbourClipboard.h \
+ include/HarbourColorEditorModel.h \
include/HarbourDebug.h \
include/HarbourDisplayBlanking.h \
include/HarbourJson.h \
include/HarbourLib.h \
include/HarbourMediaPlugin.h \
+ include/HarbourObject.h \
include/HarbourOrganizeListModel.h \
include/HarbourPolicyPlugin.h \
+ include/HarbourProcessState.h \
include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
include/HarbourSingleImageProvider.h \
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourAztecCodeGenerator.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,25 +39,42 @@
class HarbourAztecCodeGenerator : public QObject {
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(int ecLevel READ ecLevel WRITE setEcLevel NOTIFY ecLevelChanged)
Q_PROPERTY(QString code READ code NOTIFY codeChanged)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+ Q_ENUMS(ECLevel)
public:
+ enum ECLevel {
+ ECLevelDefault = -1,
+ ECLevelLowest = 5,
+ ECLevelLow = 10,
+ ECLevelMedium = 23,
+ ECLevelHigh = 36,
+ ECLevelVeryHigh = 50,
+ ECLevelHighest = 95,
+ ECLevelCount
+ };
+
HarbourAztecCodeGenerator(QObject* aParent = Q_NULLPTR);
QString text() const;
void setText(QString aValue);
+ int ecLevel() const;
+ void setEcLevel(int aValue);
+
QString code() const;
bool running() const;
- static QByteArray generate(QString aText);
+ static QByteArray generate(QString aText, int aEcLevel = ECLevelDefault);
// Callback for qmlRegisterSingletonType<HarbourAztecCodeGenerator>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
Q_SIGNALS:
void textChanged();
+ void ecLevelChanged();
void codeChanged();
void runningChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourBase32.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -31,8 +31,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HARBOUR_IMAGE_BASE32_H
-#define HARBOUR_IMAGE_BASE32_H
+#ifndef HARBOUR_BASE32_H
+#define HARBOUR_BASE32_H
#include <QString>
#include <QByteArray>
@@ -46,4 +46,4 @@
static bool isValidBase32(QString aBase32);
};
-#endif // HARBOUR_IMAGE_BASE32_H
+#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourBase45.h
^
|
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_BASE45_H
+#define HARBOUR_BASE45_H
+
+#include <QString>
+#include <QByteArray>
+
+class HarbourBase45 {
+ class Private;
+ HarbourBase45();
+public:
+ static bool isValidBase45(QString aBase45);
+ static QByteArray fromBase45(QString aBase45);
+ static QString toBase45(QByteArray aBinary);
+};
+
+#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourColorEditorModel.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_COLOR_EDITOR_MODEL_H
+#define HARBOUR_COLOR_EDITOR_MODEL_H
+
+#include <QList>
+#include <QColor>
+#include <QAbstractListModel>
+
+class HarbourColorEditorModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList colors READ getColors WRITE setColors NOTIFY colorsChanged)
+ Q_PROPERTY(int dragPos READ getDragPos WRITE setDragPos NOTIFY dragPosChanged)
+ Q_ENUMS(ItemType)
+
+public:
+ enum ItemType {
+ ColorItem,
+ TrashedItem,
+ AddItem
+ };
+
+ HarbourColorEditorModel(QObject* aParent = Q_NULLPTR);
+
+ QStringList getColors() const;
+ void setColors(QStringList aColors);
+
+ int getDragPos() const;
+ void setDragPos(int pos);
+
+ Q_INVOKABLE void addColor(QColor aColor);
+ Q_INVOKABLE int indexOf(QColor aColor) const;
+
+ // QAbstractListModel
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex& aParent) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void colorsChanged();
+ void dragPosChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_COLOR_EDITOR_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourObject.h
^
|
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef HARBOUR_OBJECT_H
+#define HARBOUR_OBJECT_H
+
+#include <QObject>
+#include <QList>
+#include <QQmlListProperty>
+
+// Fixes the "Cannot assign to non-existent default property" problem
+// with QtObject in QML.
+class HarbourObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QObject> children READ children)
+ Q_CLASSINFO("DefaultProperty", "children")
+
+public:
+ HarbourObject(QObject* aParent = Q_NULLPTR);
+
+ QQmlListProperty<QObject> children();
+
+private:
+ QList<QObject*> iChidren;
+};
+
+#endif // HARBOUR_OBJECT_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourProcessState.h
^
|
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_PROCESS_STATE_H
+#define HARBOUR_PROCESS_STATE_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourProcessState: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourProcessState)
+ Q_PROPERTY(bool jailedApp READ isJailedApp CONSTANT)
+ Q_PROPERTY(bool privileged READ isPrivileged CONSTANT)
+
+public:
+ explicit HarbourProcessState(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourProcessState>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ static bool isJailedApp();
+ static bool isPrivileged();
+};
+
+#endif // HARBOUR_PROCESS_STATE_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourQrCodeGenerator.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -39,26 +39,43 @@
class HarbourQrCodeGenerator : public QObject {
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(int ecLevel READ ecLevel WRITE setEcLevel NOTIFY ecLevelChanged)
Q_PROPERTY(QString code READ code NOTIFY codeChanged)
Q_PROPERTY(QString qrcode READ code NOTIFY codeChanged)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+ Q_ENUMS(ECLevel)
public:
+ enum ECLevel {
+ ECLevelDefault = -1,
+ ECLevelLowest = 0,
+ ECLevel_L = ECLevelLowest,
+ ECLevel_M,
+ ECLevel_Q,
+ ECLevel_H,
+ ECLevelHighest = ECLevel_H,
+ ECLevelCount
+ };
+
HarbourQrCodeGenerator(QObject* aParent = Q_NULLPTR);
QString text() const;
void setText(QString aValue);
+ ECLevel ecLevel() const;
+ void setEcLevel(int aValue);
+
QString code() const;
bool running() const;
- static QByteArray generate(QString aText);
+ static QByteArray generate(QString aText, ECLevel aEcLevel = ECLevelDefault);
// Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
Q_SIGNALS:
void textChanged();
+ void ecLevelChanged();
void codeChanged();
void runningChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourSystemInfo.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2020-2021 Jolla Ltd.
+ * Copyright (C) 2020-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -61,7 +61,11 @@
QString osName() const;
QString osVersion() const;
+ Q_INVOKABLE QString packageVersion(QString aPackage);
Q_INVOKABLE int osVersionCompare(QString aVersion);
+ Q_INVOKABLE static int compareVersions(QString aVersion1, QString aVersion2);
+
+ static QString queryPackageVersion(QString aVersion);
static int osVersionCompareWith(QString aVersion);
private:
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourTemporaryFile.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* modification, are permitted provided that the following conditions
* are met:
*
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Jolla Ltd nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
*/
#ifndef HARBOUR_TEMPORARY_FILE_H
@@ -44,17 +48,27 @@
Q_PROPERTY(QString fileTemplate READ fileTemplate WRITE setFileTemplate NOTIFY fileTemplateChanged)
Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged)
Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged)
+ Q_PROPERTY(Location location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
+ Q_ENUMS(Location)
public:
+ enum Location {
+ Tmp,
+ Downloads
+ };
+
explicit HarbourTemporaryFile(QObject* aParent = NULL);
~HarbourTemporaryFile();
QString content() const;
- void setContent(QString value);
+ void setContent(QString aValue);
QString fileTemplate() const;
- void setFileTemplate(QString value);
+ void setFileTemplate(QString aValue);
+
+ Location location() const;
+ void setLocation(Location aValue);
QString fileName() const;
QUrl url() const;
@@ -63,6 +77,7 @@
void fileTemplateChanged();
void contentChanged();
void fileNameChanged();
+ void locationChanged();
void urlChanged();
private:
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -81,6 +81,8 @@
qreal opacityHigh() const;
qreal opacityOverlay() const;
+ static QRgb invertedRgb(QRgb aRgb);
+
Q_INVOKABLE static QColor invertedColor(const QColor& aColor);
Q_INVOKABLE static qreal colorDifference(const QColor& aColor1, const QColor& aColor2);
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,6 +39,9 @@
property real maxWidth: parent.width
property alias text: label.text
+ property alias backgroundColor: background.color
+ property alias textColor: label.color
+
readonly property real radius: height/2
width: Math.max(label.implicitWidth + radius, height)
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourColorEditorDialog.qml
^
|
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ readonly property color selectedColor: sampleItem.color
+ property color initialColor: Theme.highlightColor
+ property string acceptText: "Add color"
+ property alias hueSliderText: hueSlider.label // "Color"
+ property alias brightnessSliderText: brightnessSlider.label // "Brightness"
+ property string hexNotationText: "Hex notation"
+
+ canAccept: hexText.acceptableInput
+ forwardNavigation: !hueItem.pressed
+ backNavigation: !hueItem.pressed
+
+ DialogHeader {
+ id: header
+
+ acceptText: forwardNavigation ?
+ (thisDialog.acceptText ? thisDialog.acceptText : defaultAcceptText) : ""
+ }
+
+ Component.onCompleted: hexText.text = initialColor.toString().substr(1)
+
+ // Otherwise width is changing with a delay, causing visible layout changes
+ onIsLandscapeChanged: width = isLandscape ? Screen.height : Screen.width
+
+ SilicaFlickable {
+ clip: true
+ interactive: !hueItem.pressed
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: header.bottom
+ bottom: parent.bottom
+ }
+
+ HarbourColorHueItem {
+ id: hueItem
+
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ anchors {
+ top: parent.top
+ bottom: toolPanel.top
+ bottomMargin: Theme.paddingSmall
+ }
+ brightness: brightnessSlider.sliderValue
+ onTapped: hueSlider.value = h
+ }
+
+ Column {
+ id: toolPanel
+
+ width: parent.width
+ anchors.bottom: parent.bottom
+
+ Slider {
+ id: hueSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ label: "Color"
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Slider {
+ id: brightnessSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ label: "Brightness"
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Item {
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ height: hexText.height
+ Row {
+ spacing: Theme.paddingSmall
+
+ Label {
+ id: hexLabel
+
+ y: hexText.textTopMargin
+ text: "#"
+ font.pixelSize: Theme.fontSizeLarge
+ }
+
+ Item {
+ readonly property int maxWidth: toolPanel.width - 2 * Theme.horizontalPageMargin - hexLabel.width - parent.spacing - Theme.paddingLarge - sample.width
+ width: Math.min(Math.max(textLabelTemplate.implicitWidth, Theme.itemSizeHuge), maxWidth)
+ height: hexText.height
+
+ Label {
+ id: textLabelTemplate
+
+ // Same text as hexText.label
+ text: hexNotationText
+ font.pixelSize: Theme.fontSizeSmall
+ opacity: 0
+ }
+
+ TextField {
+ id: hexText
+
+ property int ignoreTextUpdates // to avoid binding loops
+ property color tmpColor
+
+ font.pixelSize: Theme.fontSizeLarge
+ width: parent.width
+ textLeftMargin: 0
+ textRightMargin: 0
+ label: hexNotationText
+ validator: RegExpValidator { regExp: /^[0-9a-fA-F]{6}$/ }
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ EnterKey.onClicked: hexText.focus = false
+
+ onTextChanged: {
+ if (!ignoreTextUpdates) {
+ // acceptableInput hasn't been updated yet
+ syncTimer.restart()
+ }
+ }
+
+ onActiveFocusChanged: {
+ if (!activeFocus && !acceptableInput) {
+ updateText()
+ }
+ }
+
+ function syncColor() {
+ if (acceptableInput) {
+ tmpColor = "#" + text
+ ignoreTextUpdates++
+ brightnessSlider.value = hueItem.getV(tmpColor)
+ hueSlider.value = hueItem.getH(tmpColor)
+ ignoreTextUpdates--
+ }
+ }
+
+ function updateText() {
+ if (!ignoreTextUpdates) {
+ ignoreTextUpdates++
+ var s = hueItem.getColor(hueSlider.sliderValue).toString()
+ text = (s.length > 0 && s.charAt(0) === '#') ? s.substr(1) : s
+ ignoreTextUpdates--
+ }
+ }
+
+ Timer {
+ id: syncTimer
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourColorHueItem.qml
^
|
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Rectangle {
+ id: thisItem
+
+ color: "black"
+
+ property alias brightness: mouseArea.opacity
+ property alias pressed: mouseArea.pressed
+
+ readonly property color color0: "#ffffff" // 1.0
+ readonly property color color1: "#ff0000" // colorStop7
+ readonly property color color2: "#ff00ff" // colorStop6
+ readonly property color color3: "#0000ff" // colorStop5
+ readonly property color color4: "#00ffff" // colorStop4
+ readonly property color color5: "#00ff00" // colorStop3
+ readonly property color color6: "#ffff00" // colorStop2
+ readonly property color color7: "#ff0000" // colorStop1
+ readonly property color color8: "#ffffff" // 0.0
+
+ readonly property real colorStop1: 0.125
+ readonly property real colorStop2: 0.250
+ readonly property real colorStop3: 0.375
+ readonly property real colorStop4: 0.500
+ readonly property real colorStop5: 0.625
+ readonly property real colorStop6: 0.750
+ readonly property real colorStop7: 0.875
+ readonly property real hueLast: colorStop7
+ readonly property real hueRange: hueLast - colorStop1
+
+ signal tapped(var h)
+
+ function getColor(h) {
+ if (h < colorStop4) {
+ if (h > colorStop3) {
+ // colorStop3..colorStop4
+ return averageColor(color3, color4, (h - colorStop3)/(colorStop4 - colorStop3), brightness)
+ } else if (h > colorStop2) {
+ // colorStop2..colorStop3
+ return averageColor(color2, color3, (h - colorStop2)/(colorStop3 - colorStop2), brightness)
+ } else if (h > colorStop1) {
+ // colorStop1..colorStop2
+ return averageColor(color1, color2, (h - colorStop1)/(colorStop2 - colorStop1), brightness)
+ } else if (h > 0) {
+ // 0..colorStop1
+ return averageColor(color0, color1, h/colorStop1, brightness)
+ } else {
+ return adjustColor(color0, brightness)
+ }
+ } else {
+ if (h < colorStop5) {
+ // colorStop4..colorStop5
+ return averageColor(color4, color5, (h - colorStop4)/(colorStop5 - colorStop4), brightness)
+ } else if (h < colorStop6) {
+ // colorStop5..colorStop6
+ return averageColor(color5, color6, (h - colorStop5)/(colorStop6 - colorStop5), brightness)
+ } else if (h < colorStop7) {
+ // colorStop6..colorStop7
+ return averageColor(color6, color7, (h - colorStop6)/(colorStop7 - colorStop6), brightness)
+ } else if (h < 1) {
+ // colorStop7..1
+ return averageColor(color7, color8, (h - colorStop7)/(1 - colorStop7), brightness)
+ } else {
+ return adjustColor(color8, brightness)
+ }
+ }
+ }
+
+ function averageColor(c1,c2,h,v) {
+ return Qt.rgba((c1.r + (c2.r - c1.r) * h) * v,
+ (c1.g + (c2.g - c1.g) * h) * v,
+ (c1.b + (c2.b - c1.b) * h) * v, 1)
+ }
+
+ function adjustColor(c,v) {
+ return Qt.rgba(c.r * v, c.g * v, c.b * v, 1)
+ }
+
+ function getV(c) {
+ return Math.max(c.r, c.g, c.b)
+ }
+
+ function getH(c) {
+ var max = Math.max(c.r, c.g, c.b)
+ var min = Math.min(c.r, c.g, c.b)
+ var chroma = max - min
+ if (chroma === 0) {
+ return 0
+ } else {
+ if (max === c.r) {
+ return hueLast - (c.g - c.b)/chroma/6 * hueRange
+ } else if (max === c.g) {
+ return hueLast - (2 + (c.b - c.r)/chroma)/6 * hueRange
+ } else {
+ return hueLast - (4 + (c.r - c.g)/chroma)/6 * hueRange
+ }
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ width: parent.height
+ height: parent.width
+ anchors.centerIn: parent
+ rotation: -90
+
+ ShaderEffectSource {
+ anchors.fill: parent
+ sourceItem: Rectangle {
+ width: mouseArea.width
+ height: mouseArea.height
+ radius: Theme.paddingSmall
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: color0 }
+ GradientStop { position: colorStop1; color: color1 }
+ GradientStop { position: colorStop2; color: color2 }
+ GradientStop { position: colorStop3; color: color3 }
+ GradientStop { position: colorStop4; color: color4 }
+ GradientStop { position: colorStop5; color: color5 }
+ GradientStop { position: colorStop6; color: color6 }
+ GradientStop { position: colorStop7; color: color7 }
+ GradientStop { position: 1.0; color: color8 }
+ }
+ }
+ }
+ // mouseY/height because we are rotated
+ onClicked: thisItem.tapped(mouseY/height)
+ onPositionChanged: thisItem.tapped(mouseY/height)
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourColorPickerDialog.qml
^
|
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ property color color
+ property alias colorModel: grid.model // HarbourColorEditorModel
+
+ // Localizable strings
+ property alias resetColorsMenuText: resetColorsMenuItem.text // "Reset colors"
+ property string acceptText: "Select color"
+ property string addColorAcceptText: "Add color"
+ property string addColorHueSliderText: "Color"
+ property string addColorBrightnessSliderText: "Brightness"
+ property string addColorHexNotationText: "Hex notation"
+
+ forwardNavigation: false
+
+ signal resetColors()
+
+ // Constants used by HarbourColorEditorModel
+ readonly property int itemTypeColor: 0
+ readonly property int itemTypeTrash: 1
+ readonly property int itemTypeAdd: 2
+
+ SilicaGridView {
+ id: grid
+
+ cellWidth: Math.floor(width/cellsPerRow)
+ cellHeight: cellWidth
+ anchors.fill: parent
+
+ VerticalScrollDecorator {}
+
+ PullDownMenu {
+ MenuItem {
+ id: resetColorsMenuItem
+
+ text: "Reset colors"
+ onClicked: thisDialog.resetColors()
+ }
+ }
+
+ property Item dragItem
+ property int pageHeaderHeight
+ readonly property int cellsPerRow: Math.floor(width / Theme.itemSizeHuge)
+
+ header: DialogHeader {
+ dialog: thisDialog
+ acceptText: thisDialog.acceptText
+ spacing: 0
+ Component.onCompleted: grid.pageHeaderHeight = height
+ onHeightChanged: grid.pageHeaderHeight = height
+ }
+
+ delegate: MouseArea {
+ id: colorDelegate
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+
+ drag.target: dragging ? colorItem : null
+ drag.axis: Drag.XandYAxis
+
+ readonly property bool highlighted: (pressed && containsMouse)
+ readonly property bool dragging: grid.dragItem === colorDelegate
+ readonly property int index: model.index
+
+ Rectangle {
+ id: colorItem
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+ color: model.color
+ scale: !colorDelegate.dragging ? 1 : isTrashed ? 0.8 : 1.1
+ opacity: isTrashed ? 0.8 : 1
+ layer.enabled: colorDelegate.highlighted || colorDelegate.dragging || scale > 1
+ layer.effect: HarbourPressEffect { source: colorItem }
+
+ readonly property bool isTrashed: model.itemType === itemTypeTrash
+ property real returnX
+ property real returnY
+ property bool snappingBack
+
+ Behavior on opacity { FadeAnimation { } }
+ Behavior on scale {
+ NumberAnimation {
+ easing.type: Easing.InQuad
+ duration: 150
+ }
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: opacity ? ("image://theme/graphic-close-app?" + deriveColor(model.color)) : ""
+ sourceSize: Qt.size(Theme.iconSizeLarge, Theme.iconSizeLarge)
+ opacity: (model.itemType === itemTypeTrash) ? 0.8 : 0
+ visible: opacity > 0
+ Behavior on opacity { FadeAnimation { } }
+
+ function deriveColor(color) {
+ var gray = 0.299 * color.r + 0.587 * color.g + 0.114 *color.b
+ var v = (gray > 0.5) ? 0 : 1
+ return Qt.rgba(v, v, v, color.a)
+ }
+ }
+
+ states: [
+ State {
+ name: "dragging"
+ when: colorDelegate.dragging
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorDelegate.mapToItem(grid, 0, 0).x
+ y: colorDelegate.mapToItem(grid, 0, 0).y
+ }
+ },
+ State {
+ name: "snappingBack"
+ when: !colorDelegate.dragging && colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorItem.returnX
+ y: colorItem.returnY
+ }
+ },
+ State {
+ name: "idle"
+ when: !colorDelegate.dragging && !colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: colorDelegate
+ x: 0
+ y: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "snappingBack"
+ SequentialAnimation {
+ SmoothedAnimation {
+ properties: "x,y"
+ duration: 150
+ }
+ ScriptAction { script: colorItem.snappingBack = false }
+ }
+ },
+ Transition {
+ to: "idle"
+ ScriptAction { script: colorModel.dragPos = -1 }
+ }
+ ]
+
+ Connections {
+ target: colorDelegate.dragging ? colorItem : null
+ onXChanged: colorItem.updateDragPos()
+ onYChanged: colorItem.scrollAndUpdateDragPos()
+ }
+
+ Connections {
+ target: colorDelegate.dragging ? grid : null
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourPasswordInputField.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -64,6 +64,7 @@
onActiveChanged: {
if (!Qt.application.active) {
_usePasswordEchoMode = true
+ if (!readOnly) text = "" // Reset whatever has been typed
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/qml/HarbourTextFlip.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2020 Jolla Ltd.
- * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -41,6 +41,7 @@
property real duration: 500
property bool enabled: true
property string property: "text"
+ readonly property bool running: animation.running
property var animation: SequentialAnimation {
alwaysRunToEnd: true
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourAztecCodeGenerator.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -48,22 +48,25 @@
class HarbourAztecCodeGenerator::Task : public HarbourTask {
Q_OBJECT
public:
- Task(QThreadPool* aPool, QString aText);
+ Task(QThreadPool* aPool, QString aText, int aEcLevel);
void performTask() Q_DECL_OVERRIDE;
public:
QString iText;
QString iCode;
+ int iEcLevel;
};
-HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText,
+ int aEcLevel) :
HarbourTask(aPool),
- iText(aText)
+ iText(aText),
+ iEcLevel(aEcLevel)
{
}
void HarbourAztecCodeGenerator::Task::performTask()
{
- QByteArray bytes(generate(iText));
+ QByteArray bytes(generate(iText, iEcLevel));
if (!bytes.isEmpty()) {
iCode = HarbourBase32::toBase32(bytes);
}
@@ -82,6 +85,10 @@
HarbourAztecCodeGenerator* parentObject() const;
void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static int realEcLevel(int aEcLevel);
public Q_SLOTS:
void onTaskDone();
@@ -89,6 +96,7 @@
public:
QThreadPool* iThreadPool;
Task* iTask;
+ int iEcLevel;
QString iText;
QString iCode;
};
@@ -96,7 +104,8 @@
HarbourAztecCodeGenerator::Private::Private(HarbourAztecCodeGenerator* aParent) :
QObject(aParent),
iThreadPool(new QThreadPool(this)),
- iTask(Q_NULLPTR)
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
{
// Serialize the tasks:
iThreadPool->setMaxThreadCount(1);
@@ -112,19 +121,45 @@
return qobject_cast<HarbourAztecCodeGenerator*>(parent());
}
+int HarbourAztecCodeGenerator::Private::realEcLevel(int aEcLevel)
+{
+ return (aEcLevel == ECLevelDefault) ? AZTEC_CORRECTION_DEFAULT :
+ (aEcLevel < ECLevelLowest) ? ECLevelLowest :
+ (aEcLevel > ECLevelHighest) ? ECLevelHighest :
+ aEcLevel;
+}
+
void HarbourAztecCodeGenerator::Private::setText(QString aText)
{
if (iText != aText) {
iText = aText;
- HarbourAztecCodeGenerator* obj = parentObject();
- const bool wasRunning = (iTask != Q_NULLPTR);
- if (iTask) iTask->release(this);
- iTask = new Task(iThreadPool, aText);
- iTask->submit(this, SLOT(onTaskDone()));
- Q_EMIT obj->textChanged();
- if (!wasRunning) {
- Q_EMIT obj->runningChanged();
+ regenerate();
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::setEcLevel(int aValue)
+{
+ const int level = (aValue == ECLevelDefault) ? ECLevelDefault : realEcLevel(aValue);
+ if (iEcLevel != level) {
+ const int prevRealLevel = realEcLevel(iEcLevel);
+ iEcLevel = level;
+ HDEBUG(level);
+ if (realEcLevel(level) != prevRealLevel) {
+ regenerate();
}
+ Q_EMIT parentObject()->ecLevelChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::regenerate()
+{
+ const bool wasRunning = (iTask != Q_NULLPTR);
+ if (iTask) iTask->release(this);
+ iTask = new Task(iThreadPool, iText, iEcLevel);
+ iTask->submit(this, SLOT(onTaskDone()));
+ if (!wasRunning) {
+ Q_EMIT parentObject()->runningChanged();
}
}
@@ -169,6 +204,16 @@
iPrivate->setText(aValue);
}
+int HarbourAztecCodeGenerator::ecLevel() const
+{
+ return iPrivate->iEcLevel;
+}
+
+void HarbourAztecCodeGenerator::setEcLevel(int aValue)
+{
+ iPrivate->setEcLevel(aValue);
+}
+
QString HarbourAztecCodeGenerator::code() const
{
return iPrivate->iCode;
@@ -179,12 +224,12 @@
return iPrivate->iTask != Q_NULLPTR;
}
-QByteArray HarbourAztecCodeGenerator::generate(QString aText)
+QByteArray HarbourAztecCodeGenerator::generate(QString aText, int aEcLevel)
{
HDEBUG(aText);
QByteArray in(aText.toUtf8()), out;
AztecSymbol* aztec = aztec_encode_inv(in.constData(), in.size(),
- AZTEC_CORRECTION_DEFAULT);
+ Private::realEcLevel(aEcLevel));
if (aztec) {
const int bytesPerRow = (aztec->size + 7) / 8;
out.reserve(bytesPerRow * aztec->size);
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase45.h"
+
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourBase45::Private
+// ==========================================================================
+
+class HarbourBase45::Private {
+public:
+ enum {
+ BASE = 45,
+ BASE2 = BASE * BASE,
+ REVERSE_MAP_SIZE = 91
+ };
+ static const char mapBase45[BASE];
+ static const int reverseMapBase45[REVERSE_MAP_SIZE];
+ static bool isValidChar(uint x);
+};
+
+const char HarbourBase45::Private::mapBase45[HarbourBase45::Private::BASE] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+ 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
+ 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
+ '+', '-', '.', '/', ':'
+};
+
+const int HarbourBase45::Private::reverseMapBase45[HarbourBase45::Private::REVERSE_MAP_SIZE] = {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ 36, -1, -1, -1, 37, 38, -1, -1,
+ -1, -1, 39, 40, -1, 41, 42, 43,
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 44, -1, -1, -1, -1, -1,
+ -1, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35
+};
+
+inline bool HarbourBase45::Private::isValidChar(uint x)
+{
+ return (x < Private::REVERSE_MAP_SIZE) && Private::reverseMapBase45[x] >= 0;
+}
+
+// ==========================================================================
+// HarbourBase45::Private
+// ==========================================================================
+
+bool HarbourBase45::isValidBase45(QString aBase45)
+{
+ const int len = aBase45.length();
+
+ if (!((len % 3) % 2)) {
+ const QChar* chars = aBase45.constData();
+ int i = 0;
+
+ while ((i + 2) < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+ const uint e = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ !Private::isValidChar(e) ||
+ (Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE +
+ Private::reverseMapBase45[e] * Private::BASE2) > 0xffff) {
+ return false;
+ }
+ }
+
+ if (i < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ (Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE) > 0xff) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+QByteArray HarbourBase45::fromBase45(QString aBase45)
+{
+ QByteArray out;
+ const int len = aBase45.length();
+ const int tail = (len % 3);
+
+ if (!(tail % 2)) {
+ const QChar* chars = aBase45.constData();
+ int i = 0;
+
+ out.reserve(len/3*2 + tail/2);
+ while ((i + 2) < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+ const uint e = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ !Private::isValidChar(e)) {
+ return QByteArray();
+ }
+ const uint n = Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE +
+ Private::reverseMapBase45[e] * Private::BASE2;
+ if (n > 0xffff) {
+ return QByteArray();
+ }
+ char ab[2];
+ ab[0] = (char)(n >> 8);
+ ab[1] = (char)n;
+ out.append(ab, sizeof(ab));
+ }
+
+ if (i < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d)) {
+ return QByteArray();
+ }
+ const uint a = Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE;
+ if (a > 0xff) {
+ return QByteArray();
+ }
+ out.append((char)a);
+ }
+ }
+ return out;
+}
+
+QString HarbourBase45::toBase45(QByteArray aBinary)
+{
+ const uchar* ptr = (uchar*)aBinary.constData();
+ const int n = aBinary.size();
+ int i;
+
+ QString str;
+ str.reserve(3 * (n / 2) + 2 * (n % 2));
+ for (i = 0; (i + 1) < n; i += 2) {
+ uint e = (uint)(ptr[i]) * 256 + ptr[i+1];
+ const uchar c = (uchar)(e % Private::BASE);
+ e = (e - c)/Private::BASE;
+ const uchar d = (uchar)(e % Private::BASE);
+ e = (e - d)/Private::BASE;
+ str.append(QChar::fromLatin1(Private::mapBase45[c]));
+ str.append(QChar::fromLatin1(Private::mapBase45[d]));
+ str.append(QChar::fromLatin1(Private::mapBase45[e]));
+ }
+ if (i < n) {
+ uchar d = ptr[i];
+ const uchar c = d % Private::BASE;
+ d = (d - c)/Private::BASE;
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourColorEditorModel.cpp
^
|
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourColorEditorModel.h"
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+class HarbourColorEditorModel::Private
+{
+public:
+ enum ModelRole {
+ ColorRole = Qt::UserRole,
+ ItemTypeRole
+ };
+
+ Private();
+
+ bool resetDragPos();
+ QStringList getColors() const;
+ QList<QColor> makeColors(const QStringList& aColors, bool* aChanged) const;
+ QVariant data(int aRow, ModelRole aRole) const;
+
+public:
+ int iDragPos;
+ int iDragStartPos;
+ QList<QColor> iColors;
+ const QColor iAddColor;
+};
+
+HarbourColorEditorModel::Private::Private() :
+ iDragPos(-1),
+ iDragStartPos(-1),
+ iAddColor(0, 0, 0, 0)
+{
+}
+
+bool HarbourColorEditorModel::Private::resetDragPos()
+{
+ if (iDragPos >= 0) {
+ iDragPos = -1;
+ iDragStartPos = -1;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QStringList HarbourColorEditorModel::Private::getColors() const
+{
+ const int n = iColors.count();
+ QStringList colors;
+ colors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ colors.append(iColors.at(i).name());
+ }
+ return colors;
+}
+
+QList<QColor> HarbourColorEditorModel::Private::makeColors(const QStringList& aColors, bool* aChanged) const
+{
+ const int n = aColors.count();
+ *aChanged = iColors.count() != n;
+ QList<QColor> newColors;
+ newColors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ const QColor c(aColors.at(i));
+ newColors.append(c);
+ if (!*aChanged && iColors.at(i) != c) {
+ *aChanged = true;
+ }
+ }
+ return newColors;
+}
+
+QVariant HarbourColorEditorModel::Private::data(int aRow, ModelRole aRole) const
+{
+ const int n = iColors.count();
+ if (aRow >= 0 && aRow <= n) {
+ switch (aRole) {
+ case ColorRole:
+ if (iDragPos >= 0) {
+ if (aRow == iDragPos) {
+ // This includes the item dragged outside
+ return iColors.at(iDragStartPos);
+ } else {
+ if (iDragPos == n && aRow == (n - 1)) {
+ // When item is dragged outside, it becomes
+ // the last one and shifts the "add" item.
+ return iAddColor;
+ } else if (aRow >= iDragStartPos && aRow < iDragPos) {
+ return iColors.at(aRow + 1);
+ } else if (aRow > iDragPos && aRow <= iDragStartPos) {
+ return iColors.at(aRow - 1);
+ }
+ }
+ }
+ return (aRow == n) ? iAddColor : iColors.at(aRow);
+ case ItemTypeRole:
+ if (iDragPos == n) {
+ // Item is dragged outside
+ return (aRow == n) ? TrashedItem :
+ (aRow == (n - 1)) ? AddItem : ColorItem;
+ } else {
+ return (aRow == n) ? AddItem : ColorItem;
+ }
+ }
+ }
+ return QVariant();
+}
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+HarbourColorEditorModel::HarbourColorEditorModel(QObject* aParent) :
+ QAbstractListModel(aParent),
+ iPrivate(new Private)
+{
+}
+
+QHash<int,QByteArray> HarbourColorEditorModel::roleNames() const
+{
+ QHash<int,QByteArray> roles;
+ roles.insert(Private::ColorRole, "color");
+ roles.insert(Private::ItemTypeRole, "itemType");
+ return roles;
+}
+
+int HarbourColorEditorModel::rowCount(const QModelIndex&) const
+{
+ return iPrivate->iColors.count() + 1;
+}
+
+QVariant HarbourColorEditorModel::data(const QModelIndex& aIndex, int aRole) const
+{
+ return iPrivate->data(aIndex.row(), (Private::ModelRole)aRole);
+}
+
+QStringList HarbourColorEditorModel::getColors() const
+{
+ return iPrivate->getColors();
+}
+
+void HarbourColorEditorModel::setColors(QStringList aColors)
+{
+ bool changed;
+ const QList<QColor> prevColors(iPrivate->iColors);
+ const QList<QColor> newColors(iPrivate->makeColors(aColors, &changed));
+ if (changed) {
+ const int prevCount = prevColors.count();
+ const int newCount = newColors.count();
+ const QVector<int> colorRole(1, Private::ColorRole);
+ if (newCount < prevCount) {
+ beginRemoveRows(QModelIndex(), newCount + 1, prevCount);
+ iPrivate->iColors = newColors;
+ endRemoveRows();
+ } else if (newCount > prevCount) {
+ beginInsertRows(QModelIndex(), prevCount + 1, newCount);
+ iPrivate->iColors = newColors;
+ endInsertRows();
+ } else {
+ iPrivate->iColors = newColors;
+ }
+ // Change the colors
+ int rangeStart = -1;
+ const int n = qMin(prevCount, newCount);
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourObject.cpp
^
|
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "HarbourObject.h"
+
+HarbourObject::HarbourObject(QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+QQmlListProperty<QObject> HarbourObject::children()
+{
+ return QQmlListProperty<QObject>(this, iChidren);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017-2020 Jolla Ltd.
- * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -78,6 +78,24 @@
// sym,ret,name,args
#define QMLTYPE_FUNCTIONS(f) \
+ f("_ZN12QQmlMetaType7qmlTypeERK7QStringii", \
+ QQmlType*, qmlType, (QString const&, int, int)) \
+ f("_ZNK8QQmlType23propertyValueSourceCastEv", \
+ int, propertyValueSourceCast, (QQmlType*)) \
+ f("_ZNK8QQmlType10createSizeEv", \
+ int, createSize, (QQmlType*)) \
+ f("_ZNK8QQmlType10metaObjectEv", \
+ const QMetaObject*, metaObject, (QQmlType*)) \
+ f("_ZNK8QQmlType16parserStatusCastEv", \
+ int, parserStatusCast, (QQmlType*)) \
+ f("_ZNK8QQmlType28propertyValueInterceptorCastEv", \
+ int, propertyValueInterceptorCast, (QQmlType*)) \
+ f("_ZNK8QQmlType6typeIdEv", \
+ int, typeId, (QQmlType*)) \
+ f("_ZNK8QQmlType14createFunctionEv", \
+ QQmlType::CreateFunc, createFunction, (QQmlType*)) \
+ f("_ZNK8QQmlType11qListTypeIdEv", \
+ int, qListTypeId, (QQmlType*)) \
f("_ZNK8QQmlType26attachedPropertiesFunctionEv", \
QQmlAttachedPropertiesFunc, AttachedPropertiesFunctionProc,(QQmlType*)) \
f("_ZNK8QQmlType22attachedPropertiesTypeEv", \
@@ -100,8 +118,8 @@
int parserStatusCast() const;
int propertyValueSourceCast() const;
int propertyValueInterceptorCast() const;
- QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
- const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const;
+ // attachedPropertiesFunction
+ // attachedPropertiesType
};
// PRIVATE QT API!
@@ -219,8 +237,10 @@
HarbourPluginLoader::Private::qmlType(
QString aName)
{
- QString fullName(iModule + '/' + aName);
- QQmlType* type = QQmlMetaType::qmlType(fullName, iMajor, iMinor);
+ const QString fullName(iModule + '/' + aName);
+ QQmlType* type = gLibQt5Qml.iSym.fn.qmlType ?
+ gLibQt5Qml.iSym.fn.qmlType(fullName, iMajor, iMinor) :
+ Q_NULLPTR;
if (!type) {
HWARN("Failed to load" << fullName);
}
@@ -259,7 +279,15 @@
int aMajor,
int aMinor)
{
- if (aType && iEngine) {
+ if (aType && iEngine &&
+ gLibQt5Qml.iSym.fn.typeId &&
+ gLibQt5Qml.iSym.fn.qListTypeId &&
+ gLibQt5Qml.iSym.fn.createSize &&
+ gLibQt5Qml.iSym.fn.createFunction &&
+ gLibQt5Qml.iSym.fn.metaObject &&
+ gLibQt5Qml.iSym.fn.parserStatusCast &&
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast &&
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast) {
// Get around the ABI break in Qt 5.6
QQmlAttachedPropertiesFunc attachedPropertiesFunction =
gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc ?
@@ -275,21 +303,21 @@
NULL;
QQmlPrivate::RegisterType type = {
0, // int version;
- aType->typeId(), // int typeId;
- aType->qListTypeId(), // int listId;
- aType->createSize(), // int objectSize;
- aType->createFunction(), // void (*create)(void *);
+ gLibQt5Qml.iSym.fn.typeId(aType), // int typeId;
+ gLibQt5Qml.iSym.fn.qListTypeId(aType), // int listId;
+ gLibQt5Qml.iSym.fn.createSize(aType), // int objectSize;
+ gLibQt5Qml.iSym.fn.createFunction(aType), // void (*create)(void *);
QString(), // QString noCreationReason;
aModule, // const char *uri;
aMajor, // int versionMajor;
aMinor, // int versionMinor;
aQmlName, // const char *elementName;
- aType->metaObject(), // const QMetaObject *metaObject;
+ gLibQt5Qml.iSym.fn.metaObject(aType), // const QMetaObject *metaObject;
attachedPropertiesFunction,
attachedPropertiesMetaObject,
- aType->parserStatusCast(), // int parserStatusCast;
- aType->propertyValueSourceCast(), // int valueSourceCast;
- aType->propertyValueInterceptorCast(), // int valueInterceptorCast;
+ gLibQt5Qml.iSym.fn.parserStatusCast(aType), // int parserStatusCast;
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast(aType), // int valueSourceCast;
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast(aType), // int valueInterceptorCast;
Q_NULLPTR, // QObject *(*extensionObjectCreate)(QObject *);
Q_NULLPTR, // const QMetaObject *extensionMetaObject;
Q_NULLPTR, // QQmlCustomParser *customParser;
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourProcessState.cpp
^
|
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourProcessState.h"
+#include "HarbourDebug.h"
+
+#include <unistd.h>
+#include <grp.h>
+#include <sys/types.h>
+
+HarbourProcessState::HarbourProcessState(QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourProcessState>
+QObject* HarbourProcessState::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourProcessState;
+}
+
+bool HarbourProcessState::isJailedApp()
+{
+ static int processJailed = -1;
+
+ // Apps are not supposed to be started by the root systemd process.
+ // Firejail tells us that our parent pid is 1.
+ // We could additionally check that /proc contains only our and
+ // parent pids, if ppid check becomes not reliable enough.
+ if (processJailed < 0) {
+ bool simulate = false;
+ const char* var = "HARBOUR_JAIL_STATE";
+ processJailed = QString(qgetenv(var)).toInt(&simulate);
+ if (!simulate || processJailed < 0) {
+ if (getppid() == 1) {
+ HWARN("We are jailed!");
+ processJailed = 1;
+ } else{
+ HDEBUG("Cool, we are free!");
+ processJailed = 0;
+ }
+ } else {
+ HWARN(var << processJailed);
+ }
+ }
+ return processJailed > 0;
+}
+
+bool HarbourProcessState::isPrivileged()
+{
+ static gid_t privilegedGid = 0;
+
+ if (!privilegedGid) {
+ const struct group* gr = getgrnam("privileged");
+
+ if (gr) {
+ privilegedGid = gr->gr_gid;
+ HDEBUG("privileged =" << privilegedGid);
+ }
+ }
+ const gid_t egid = getegid();
+ if (egid == privilegedGid) {
+ HDEBUG("Yes, we are privileged :)");
+ return true;
+ } else {
+ HDEBUG("Oops, we are not privileged :(");
+ return false;
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourQrCodeGenerator.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -45,25 +45,31 @@
// HarbourQrCodeGenerator::Task
// ==========================================================================
-class HarbourQrCodeGenerator::Task : public HarbourTask {
+class HarbourQrCodeGenerator::Task : public HarbourTask
+{
Q_OBJECT
+
public:
- Task(QThreadPool* aPool, QString aText);
+ Task(QThreadPool* aPool, QString aText, ECLevel aEcLevel);
void performTask() Q_DECL_OVERRIDE;
+
public:
QString iText;
QString iCode;
+ ECLevel iEcLevel;
};
-HarbourQrCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+HarbourQrCodeGenerator::Task::Task(QThreadPool* aPool, QString aText,
+ ECLevel aEcLevel) :
HarbourTask(aPool),
- iText(aText)
+ iText(aText),
+ iEcLevel(aEcLevel)
{
}
void HarbourQrCodeGenerator::Task::performTask()
{
- QByteArray bytes(generate(iText));
+ QByteArray bytes(generate(iText, iEcLevel));
if (!bytes.isEmpty()) {
iCode = HarbourBase32::toBase32(bytes);
}
@@ -73,7 +79,8 @@
// HarbourQrCodeGenerator::Private
// ==========================================================================
-class HarbourQrCodeGenerator::Private : public QObject {
+class HarbourQrCodeGenerator::Private : public QObject
+{
Q_OBJECT
public:
@@ -82,6 +89,10 @@
HarbourQrCodeGenerator* parentObject() const;
void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static QRecLevel realEcLevel(ECLevel aEcLevel);
public Q_SLOTS:
void onTaskDone();
@@ -89,6 +100,7 @@
public:
QThreadPool* iThreadPool;
Task* iTask;
+ ECLevel iEcLevel;
QString iText;
QString iCode;
};
@@ -96,7 +108,8 @@
HarbourQrCodeGenerator::Private::Private(HarbourQrCodeGenerator* aParent) :
QObject(aParent),
iThreadPool(new QThreadPool(this)),
- iTask(Q_NULLPTR)
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
{
// Serialize the tasks:
iThreadPool->setMaxThreadCount(1);
@@ -104,6 +117,7 @@
HarbourQrCodeGenerator::Private::~Private()
{
+ if (iTask) iTask->release();
iThreadPool->waitForDone();
}
@@ -112,19 +126,52 @@
return qobject_cast<HarbourQrCodeGenerator*>(parent());
}
+QRecLevel HarbourQrCodeGenerator::Private::realEcLevel(ECLevel aEcLevel)
+{
+ switch (aEcLevel) {
+ case ECLevel_L: return QR_ECLEVEL_L;
+ case ECLevel_M: return QR_ECLEVEL_M;
+ case ECLevel_Q: return QR_ECLEVEL_Q;
+ case ECLevel_H: return QR_ECLEVEL_H;
+ case ECLevelDefault:
+ case ECLevelCount:
+ break;
+ }
+ return QR_ECLEVEL_M; // default
+}
+
void HarbourQrCodeGenerator::Private::setText(QString aText)
{
if (iText != aText) {
iText = aText;
- HarbourQrCodeGenerator* obj = parentObject();
- const bool wasRunning = (iTask != Q_NULLPTR);
- if (iTask) iTask->release(this);
- iTask = new Task(iThreadPool, aText);
- iTask->submit(this, SLOT(onTaskDone()));
- Q_EMIT obj->textChanged();
- if (!wasRunning) {
- Q_EMIT obj->runningChanged();
+ regenerate();
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourQrCodeGenerator::Private::setEcLevel(int aValue)
+{
+ const ECLevel level = (aValue < ECLevelDefault) ? ECLevelDefault :
+ (aValue > ECLevelHighest) ? ECLevelHighest : (ECLevel)aValue;
+ if (iEcLevel != level) {
+ const QRecLevel prevRealLevel = realEcLevel(iEcLevel);
+ iEcLevel = level;
+ if (realEcLevel(level) != prevRealLevel) {
+ regenerate();
}
+ Q_EMIT parentObject()->ecLevelChanged();
+ }
+}
+
+void HarbourQrCodeGenerator::Private::regenerate()
+{
+ HarbourQrCodeGenerator* obj = parentObject();
+ const bool wasRunning = (iTask != Q_NULLPTR);
+ if (iTask) iTask->release();
+ iTask = new Task(iThreadPool, iText, iEcLevel);
+ iTask->submit(this, SLOT(onTaskDone()));
+ if (!wasRunning) {
+ Q_EMIT obj->runningChanged();
}
}
@@ -156,7 +203,7 @@
// Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
QObject* HarbourQrCodeGenerator::createSingleton(QQmlEngine* aEngine, QJSEngine*)
{
- return new HarbourQrCodeGenerator(aEngine);
+ return new HarbourQrCodeGenerator(); // Singleton doesn't need a parent
}
QString HarbourQrCodeGenerator::text() const
@@ -169,6 +216,16 @@
iPrivate->setText(aValue);
}
+HarbourQrCodeGenerator::ECLevel HarbourQrCodeGenerator::ecLevel() const
+{
+ return iPrivate->iEcLevel;
+}
+
+void HarbourQrCodeGenerator::setEcLevel(int aValue)
+{
+ iPrivate->setEcLevel(aValue);
+}
+
QString HarbourQrCodeGenerator::code() const
{
return iPrivate->iCode;
@@ -179,10 +236,11 @@
return iPrivate->iTask != Q_NULLPTR;
}
-QByteArray HarbourQrCodeGenerator::generate(QString aText)
+QByteArray HarbourQrCodeGenerator::generate(QString aText, ECLevel aEcLevel)
{
QByteArray in(aText.toUtf8()), out;
- QRcode* code = QRcode_encodeString(in.constData(), 0, QR_ECLEVEL_M, QR_MODE_8, true);
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2020-2021 Jolla Ltd.
+ * Copyright (C) 2020-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -44,6 +44,12 @@
#include <QFile>
#include <QTextStream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
// ==========================================================================
// HarbourSystemInfo::Private
// ==========================================================================
@@ -63,10 +69,13 @@
static int compareVersions(const QVector<uint> aVersion1, const QVector<uint> aVersion2);
static int compareVersions(const QVector<uint> aVersion1, const QString aVersion2);
+ QString getPackageVersion(QString aPackage);
+
public:
QString iName;
QString iVersion;
QVector<uint> iParsedVersion;
+ QMap<QString,QString> iPackageVersions;
};
const QString HarbourSystemInfo::Private::NAME("NAME");
@@ -159,6 +168,21 @@
return compareVersions(aVersion1, Private::parseVersion(aVersion2));
}
+QString HarbourSystemInfo::Private::getPackageVersion(QString aPackage)
+{
+ QString version;
+ if (!aPackage.isEmpty()) {
+ version = iPackageVersions.value(aPackage);
+ if (version.isEmpty()) {
+ version = HarbourSystemInfo::queryPackageVersion(aPackage);
+ if (!version.isEmpty()) {
+ iPackageVersions.insert(aPackage, version);
+ }
+ }
+ }
+ return version;
+}
+
// ==========================================================================
// HarbourSystemInfo
// ==========================================================================
@@ -192,6 +216,11 @@
return iPrivate->iVersion;
}
+QString HarbourSystemInfo::packageVersion(QString aPackage)
+{
+ return iPrivate->getPackageVersion(aPackage);
+}
+
int HarbourSystemInfo::osVersionCompare(QString aVersion)
{
return Private::compareVersions(iPrivate->iParsedVersion, aVersion);
@@ -203,3 +232,52 @@
const QString os(Private::parseOsRelease(keys).value(Private::VERSION_ID));
return Private::compareVersions(Private::parseVersion(os), aVersion);
}
+
+int HarbourSystemInfo::compareVersions(QString aVersion1, QString aVersion2)
+{
+ return Private::compareVersions(Private::parseVersion(aVersion1),
+ Private::parseVersion(aVersion2));
+}
+
+QString HarbourSystemInfo::queryPackageVersion(QString aPackage)
+{
+ QString version;
+ int fds[2];
+ if (pipe(fds) == 0) {
+ pid_t pid = fork();
+ if (!pid) {
+ const QByteArray package(aPackage.toLatin1());
+ const char* argv[6];
+ argv[0] = "rpm";
+ argv[1] = "-q";
+ argv[2] = "--qf";
+ argv[3] = "%{version}";
+ argv[4] = package.constData();
+ argv[5] = NULL;
+ while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
+ execvp(argv[0], (char**)argv);
+ abort();
+ }
+ close(fds[1]);
+
+ // There shouldn't be much output
+ QByteArray out;
+ const int chunk = 16;
+ ssize_t n = 0;
+ do {
+ const int size = out.size();
+ out.resize(size + chunk);
+ while ((n = read(fds[0], out.data() + size, chunk)) == -1 && (errno == EINTR));
+ out.resize(size + qMax(n, (ssize_t)0));
+ } while (n > 0);
+
+ // Parse the version
+ if (out.size() > 0) {
+ version = QString::fromLatin1(out);
+ HDEBUG(qPrintable(aPackage) << qPrintable(version));
+ }
+ waitpid(pid, NULL, 0);
+ close(fds[0]);
+ }
+ return version;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourTemporaryFile.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* modification, are permitted provided that the following conditions
* are met:
*
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * - Neither the name of Jolla Ltd nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
*/
#include "HarbourTemporaryFile.h"
@@ -37,6 +41,7 @@
#include <QDir>
#include <QTemporaryFile>
#include <QTextStream>
+#include <QStandardPaths>
// ==========================================================================
// HarbourTemporaryFile::Private
@@ -48,9 +53,11 @@
~Private();
void reopen(HarbourTemporaryFile* aObject);
+ QString directoryPath() const;
QString fileName() const;
public:
+ Location iLocation;
QTemporaryFile* iFile;
QString iFileTemplate;
QString iContent;
@@ -58,7 +65,8 @@
};
HarbourTemporaryFile::Private::Private() :
- iFile(NULL)
+ iLocation(Tmp),
+ iFile(NULL)
{
}
@@ -76,6 +84,21 @@
return iFile ? iFile->fileName() : QString();
}
+QString
+HarbourTemporaryFile::Private::directoryPath() const
+{
+ QStandardPaths::StandardLocation type = QStandardPaths::TempLocation;
+ switch (iLocation) {
+ case Downloads:
+ type = QStandardPaths::DownloadLocation;
+ break;
+ case Tmp:
+ // This is the default
+ break;
+ }
+ return QStandardPaths::writableLocation(type);
+}
+
void
HarbourTemporaryFile::Private::reopen(
HarbourTemporaryFile* aObject)
@@ -89,7 +112,7 @@
iUrl = QUrl();
}
if (!iContent.isEmpty() && !iFileTemplate.isEmpty()) {
- iFile = new QTemporaryFile(QDir::tempPath() +
+ iFile = new QTemporaryFile(directoryPath() +
QDir::separator() + iFileTemplate);
iFile->setAutoRemove(true);
if (iFile->open()) {
@@ -159,6 +182,22 @@
}
}
+HarbourTemporaryFile::Location
+HarbourTemporaryFile::location() const
+{
+ return iPrivate->iLocation;
+}
+
+void
+HarbourTemporaryFile::setLocation(Location aValue)
+{
+ if (iPrivate->iLocation != aValue) {
+ iPrivate->iLocation = aValue;
+ iPrivate->reopen(this);
+ Q_EMIT locationChanged();
+ }
+}
+
QString
HarbourTemporaryFile::fileName() const
{
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -215,11 +215,15 @@
return invertedColor(Private::primaryColor());
}
+QRgb HarbourTheme::invertedRgb(QRgb aRgb)
+{
+ return ((~(aRgb & RGB_MASK)) & RGB_MASK) | (aRgb & (~RGB_MASK));
+}
+
QColor HarbourTheme::invertedColor(const QColor& aColor)
{
if (aColor.isValid()) {
- const QRgb rgba = aColor.rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
+ return QColor(invertedRgb(aColor.rgba()));
} else {
return aColor;
}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/src/libcrypto.c
^
|
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gutil_log.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <openssl/aes.h>
+#include <openssl/des.h>
+#include <openssl/md5.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
+
+/*
+ * What is this code?
+ *
+ * Sailfish OS comes in 3 flavors wrt openssl versions:
+ *
+ * 1. Sailfish OS up to 3.4 had openssl 1.0
+ * 2. Sailfish 4.0..4.2 had both openssl 1.0 and openssl 1.1 libraries
+ * 3. Sailfish 4.3 dropped openssl 1.0 libraries and only has openssl 1.1
+ *
+ * Which means that explicitly linking with any version of openssl
+ * makes your app incompatible with either Sailfish OS <= 3.4 or
+ * Sailfish OS >= 4.3 (nice symmetry).
+ *
+ * If you want to build an app which runs on both Sailfish OS <= 3.4
+ * and Sailfish OS >= 4.3 you have two options:
+ *
+ * 1. Link openssl statically
+ * 2. Load libcrypts.so dynamically with dlopen/dlsym
+ *
+ * This module allows you to implement the second strategy. It works
+ * because openssl 1.0 and 1.1 (luckily!) appear to be binary compatible.
+ * It doesn't load all libcrypto functions, only those referenced by my
+ * apps but the list can be easily expanded.
+ */
+
+#ifndef LIBDIR
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+#endif
+
+/*
+ * OpenSSL 1.0 headers define ERR_load_crypto_strings as a function:
+ *
+ * void ERR_load_crypto_strings(void);
+ *
+ * and OpenSSL 1.1 as a macro:
+ *
+ * #if OPENSSL_API_COMPAT < 0x10100000L
+ * # define ERR_load_crypto_strings() \
+ * OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ * # define ERR_free_strings() while(0) continue
+ * #endif
+ *
+ * We want to try loading both ERR_load_crypto_strings and
+ * OPENSSL_init_crypto, one of which will probably fail.
+ */
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+# undef ERR_load_crypto_strings
+#else
+# define OPENSSL_INIT_SETTINGS void
+#endif
+
+/* f(name,params,args) */
+#define LIBCRYPTO_FUNCTIONS1(f) \
+ f(AES_cbc_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key, unsigned char* ivec, const int enc), \
+ (in, out, length, key, ivec, enc)) \
+ f(AES_cfb128_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key,unsigned char* ivec, int* num, const int enc), \
+ (in, out, length, key, ivec, num, enc)) \
+ f(AES_ecb_encrypt, \
+ (const unsigned char* in, unsigned char* out, const AES_KEY* key, \
+ const int enc), \
+ (in, out, key, enc)) \
+ f(BN_free, (BIGNUM *a), (a)) \
+ f(DES_ede3_cbc_encrypt, \
+ (const unsigned char* input, unsigned char* output, long length, \
+ DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
+ DES_cblock* ivec, int enc), \
+ (input, output, length, ks1, ks2, ks3, ivec, enc)) \
+ f(ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r))
+
+/* f(ret,name,params,args,def) */
+#define LIBCRYPTO_FUNCTIONS2(f) \
+ f(int, AES_set_decrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(int, AES_set_encrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(BIGNUM*, BN_bin2bn, \
+ (const unsigned char* s, int len, BIGNUM* ret), (s, len, ret), NULL) \
+ f(int, BN_bn2bin, \
+ (const BIGNUM* a, unsigned char* to), (a, to), 0) \
+ f(BIGNUM*, BN_new, (void), (), NULL) \
+ f(int, BN_num_bits, (const BIGNUM *a), (a), 0) \
+ f(int, BN_set_word, (BIGNUM* a, BN_ULONG w), (a, w), 0) \
+ f(int, DES_check_key_parity, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_is_weak_key, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_set_key, \
+ (const_DES_cblock* key, DES_key_schedule* schedule), \
+ (key, schedule), -1) \
+ f(char*, ERR_error_string, (unsigned long e, char* buf), (e, buf), NULL) \
+ f(unsigned long, ERR_get_error, (void), (), 0) \
+ f(unsigned char*, MD5, \
+ (const unsigned char* d, size_t n, unsigned char* md), (d, n, md), NULL) \
+ f(int, MD5_Final, (unsigned char* md, MD5_CTX* c), (md, c), 0) \
+ f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
+ f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(int, OPENSSL_init_crypto, \
+ (uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
+ (opts, settings), 0) \
+ f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
+ f(int, RAND_poll, (void), (), 0) \
+ f(RSA*, RSAPrivateKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(RSA*, RSAPublicKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(int, RSA_generate_key_ex, \
+ (RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb), \
+ (rsa, bits, e, cb), 0) \
+ f(RSA*, RSA_new, (void), (), NULL) \
+ f(int, RSA_private_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_private_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
+ f(int, SHA1_Init, (SHA_CTX* c), (c), 0) \
+ f(int, SHA1_Update, (SHA_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA256, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA256_Final, (unsigned char* md, SHA256_CTX* c), (md, c), 0) \
+ f(int, SHA256_Init, (SHA256_CTX* c), (c), 0) \
+ f(int, SHA256_Update, (SHA256_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA512, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA512_Final, (unsigned char* md, SHA512_CTX* c), (md, c), 0) \
+ f(int, SHA512_Init, (SHA512_CTX* c), (c), 0) \
+ f(int, SHA512_Update, (SHA512_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0)
+
+static const char* libcrypto_so_path[] = {
+ LIBDIR "/libcrypto.so.1.1",
+ "/lib/libcrypto.so.10"
+};
+
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C TestHarbourBase32 $*
+ @$(MAKE) -C TestHarbourBase45 $*
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/Makefile.common
^
|
@@ -0,0 +1,200 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release coverage
+
+#
+# Real test makefile defines EXE (and possibly SRC) and includes this one.
+#
+
+ifndef EXE
+${error EXE not defined}
+endif
+
+SRC ?= $(EXE).cpp
+
+#
+# Required packages
+#
+
+PKGS += Qt5Core glib-2.0
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Directories
+#
+
+SRC_DIR = .
+TOP_DIR = ../..
+HARBOUR_DIR = $(TOP_DIR)
+BUILD_DIR = build
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+MOC = qtchooser -run-tool=moc -qt=5
+WARNINGS = -Wall
+INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_DIR)/include
+BASE_FLAGS = -fPIC
+BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
+BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
+FULL_CFLAGS = $(BASE_CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+FULL_LDFLAGS = $(BASE_LDFLAGS)
+LIBS = $(shell pkg-config --libs $(PKGS)) -lstdc++
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+COVERAGE_FLAGS = -g
+
+DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+COVERAGE_LDFLAGS = $(FULL_LDFLAGS) $(COVERAGE_FLAGS) --coverage
+
+DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG -DHARBOUR_DEBUG
+RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
+COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
+
+#
+# Files
+#
+
+DEBUG_OBJS = \
+ $(MOC_H:%.h=$(DEBUG_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(DEBUG_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(DEBUG_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(DEBUG_BUILD_DIR)/harbour_%.o)
+RELEASE_OBJS = \
+ $(MOC_H:%.h=$(RELEASE_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(RELEASE_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(RELEASE_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(RELEASE_BUILD_DIR)/harbour_%.o)
+COVERAGE_OBJS = \
+ $(MOC_H:%.h=$(COVERAGE_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(COVERAGE_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(COVERAGE_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(COVERAGE_BUILD_DIR)/harbour_%.o)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+COVERAGE_EXE = $(COVERAGE_BUILD_DIR)/$(EXE)
+
+debug: $(DEBUG_EXE)
+
+release: $(RELEASE_EXE)
+
+coverage: $(COVERAGE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+test_banner:
+ @echo "===========" $(EXE) "=========== "
+
+test: test_banner debug
+ @$(DEBUG_EXE)
+
+valgrind: test_banner debug
+ @G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
+
+$(BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(COVERAGE_BUILD_DIR):
+ mkdir -p $@
+
+$(BUILD_DIR)/moc_%.cpp : $(APP_DIR)/%.h
+ $(MOC) $< -o $@
+
+$(BUILD_DIR)/%.moc : $(APP_DIR)/%.cpp
+ $(MOC) $< -o $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+
+$(COVERAGE_EXE): $(COVERAGE_OBJS)
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/TestHarbourBase32/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = TestHarbourBase32
+HARBOUR_SRC = HarbourBase32.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/TestHarbourBase32/TestHarbourBase32.cpp
^
|
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase32.h"
+#include "HarbourDebug.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * isValidBase45
+ *==========================================================================*/
+
+static
+void
+test_isValidBase32(
+ void)
+{
+ g_assert(HarbourBase32::isValidBase32("AEBAGBAFAYDQQCIKBMGA2DQPCAIREEYUCULBOGI2DMOB2HQ7"));
+ g_assert(HarbourBase32::isValidBase32("aebagbaf aydqqcik bmga2dqp caireeyu culbogi2 dmob2hq7"));
+ g_assert(HarbourBase32::isValidBase32("ae"));
+ g_assert(!HarbourBase32::isValidBase32("aeb"));
+ g_assert(HarbourBase32::isValidBase32("aeba"));
+ g_assert(HarbourBase32::isValidBase32("aebag"));
+ g_assert(!HarbourBase32::isValidBase32("aebagb"));
+ g_assert(!HarbourBase32::isValidBase32("aebagb= x"));
+ g_assert(HarbourBase32::isValidBase32("aebagba"));
+ g_assert(HarbourBase32::isValidBase32("aebagbaf"));
+ g_assert(HarbourBase32::isValidBase32("aebagbafa"));
+ g_assert(HarbourBase32::isValidBase32("aebagbafay"));
+ g_assert(!HarbourBase32::isValidBase32(QString()));
+ g_assert(!HarbourBase32::isValidBase32(" "));
+ g_assert(!HarbourBase32::isValidBase32("01234567"));
+ g_assert(!HarbourBase32::isValidBase32("88888888"));
+ g_assert(!HarbourBase32::isValidBase32("{}"));
+ g_assert(!HarbourBase32::isValidBase32("[]"));
+}
+
+/*==========================================================================*
+ * fromBase32
+ *==========================================================================*/
+
+static
+void
+test_fromBase32(
+ void)
+{
+ static const char out[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
+ };
+ QString in1("AEBAGBAFAYDQQCIKBMGA2DQPCAIREEYUCULBOGI2DMOB2HQ7");
+ QString in2("aebagbaf aydqqcik bmga2dqp caireeyu culbogi2 dmob2hq7");
+ QByteArray out1(HarbourBase32::fromBase32(in1));
+ QByteArray out2(HarbourBase32::fromBase32(in2));
+ g_assert(out1 == out2);
+ g_assert(out1 == QByteArray(out, sizeof(out)));
+ g_assert(HarbourBase32::fromBase32("ae") == QByteArray(out, 1));
+ g_assert(HarbourBase32::fromBase32("aeb").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aeba") == QByteArray(out, 2));
+ g_assert(HarbourBase32::fromBase32("aebag") == QByteArray(out, 3));
+ g_assert(HarbourBase32::fromBase32("aebagb").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagb=x").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagb= x").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagba") == QByteArray(out, 4));
+ g_assert(HarbourBase32::fromBase32("aebagbaf") == QByteArray(out, 5));
+ g_assert(HarbourBase32::fromBase32("aebagbafa") == QByteArray(out, 5));
+ g_assert(HarbourBase32::fromBase32("aebagbafay") == QByteArray(out, 6));
+ g_assert(HarbourBase32::fromBase32(QString()).isEmpty());
+ g_assert(HarbourBase32::fromBase32(" ").isEmpty());
+ g_assert(HarbourBase32::fromBase32("01234567").isEmpty());
+ g_assert(HarbourBase32::fromBase32("88888888").isEmpty());
+ g_assert(HarbourBase32::fromBase32("{}").isEmpty());
+ g_assert(HarbourBase32::fromBase32("[]").isEmpty());
+}
+
+/*==========================================================================*
+ * base32pad
+ *==========================================================================*/
+
+static
+void
+test_base32pad(
+ void)
+{
+ static const char out[] = {
+ 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23
+ };
+ QString in1("DMOB2HQ7EA====="); // One pad character missing
+ QString in2("DMOB2HQ7EAQQ====="); // One extra pagging character
+ QString in3("DMOB2HQ7EAQSE== ="); // Space is ignored
+ QString in4("DMOB2HQ7EAQSEIY=");
+ g_assert(HarbourBase32::fromBase32(in1) == QByteArray(out, sizeof(out) - 3));
+ g_assert(HarbourBase32::fromBase32(in2) == QByteArray(out, sizeof(out) - 2));
+ g_assert(HarbourBase32::fromBase32(in3) == QByteArray(out, sizeof(out) - 1));
+ g_assert(HarbourBase32::fromBase32(in4) == QByteArray(out, sizeof(out)));
+ g_assert(HarbourBase32::fromBase32(QString("=================")).isEmpty());
+ g_assert(HarbourBase32::fromBase32(QString("=DMOB2HQ7EAQSEIY=")).isEmpty());
+ g_assert(HarbourBase32::fromBase32(QString("DMOB2HQ7EB=")).isEmpty());
+}
+
+/*==========================================================================*
+ * toBase32
+ *==========================================================================*/
+
+static
+void
+test_toBase32(
+ void)
+{
+ static const char in[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
+ };
+ QString out("aebagbafaydqqcikbmga2dqpcaireeyuculbogi2dmob2hq7");
+ g_assert(HarbourBase32::toBase32(QByteArray()).isEmpty());
+ g_assert(HarbourBase32::toBase32(QByteArray(in, sizeof(in))) == out);
+}
+
+/*==========================================================================*
+ * rfc4648
+ *==========================================================================*/
+
+static
+void
+test_rfc4648(
+ void)
+{
+ // Test vectors from RFC 4648
+ static const char* test[][2] = {
+ { "f", "MY======" },
+ { "fo", "MZXQ====" },
+ { "foo", "MZXW6===" },
+ { "foob", "MZXW6YQ=" },
+ { "fooba", "MZXW6YTB" },
+ { "foobar", "MZXW6YTBOI======" }
+ };
+
+ for (guint i = 0; i < G_N_ELEMENTS(test); i++) {
+ QByteArray data(test[i][0]);
+ QString base32(test[i][1]);
+ g_assert(HarbourBase32::isValidBase32(base32));
+ g_assert(HarbourBase32::fromBase32(base32) == data);
+ g_assert(HarbourBase32::toBase32(data, false) == base32);
+ }
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourBase32/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("isValidBase32"), test_isValidBase32);
+ g_test_add_func(TEST_("fromBase32"), test_fromBase32);
+ g_test_add_func(TEST_("base32pad"), test_base32pad);
+ g_test_add_func(TEST_("rfc4648"), test_rfc4648);
+ g_test_add_func(TEST_("toBase32"), test_toBase32);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/TestHarbourBase45/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = TestHarbourBase45
+HARBOUR_SRC = HarbourBase45.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/TestHarbourBase45/TestHarbourBase45.cpp
^
|
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase45.h"
+#include "HarbourDebug.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * isValidBase45
+ *==========================================================================*/
+
+static
+void
+test_isValidBase45(
+ void)
+{
+ g_assert(HarbourBase45::isValidBase45("")); // Empty is considered valid
+ g_assert(HarbourBase45::isValidBase45("BB8"));
+ g_assert(HarbourBase45::isValidBase45("%69 VD92EX0"));
+ g_assert(HarbourBase45::isValidBase45("UJCLQE7W581"));
+ g_assert(!HarbourBase45::isValidBase45("AA("));
+ g_assert(!HarbourBase45::isValidBase45("A(A"));
+ g_assert(!HarbourBase45::isValidBase45("(AA"));
+ g_assert(!HarbourBase45::isValidBase45("A("));
+ g_assert(!HarbourBase45::isValidBase45("A["));
+ g_assert(!HarbourBase45::isValidBase45("[A"));
+ g_assert(!HarbourBase45::isValidBase45("A"));
+ g_assert(!HarbourBase45::isValidBase45("ZZ"));
+ g_assert(!HarbourBase45::isValidBase45("ZZZ"));
+}
+
+/*==========================================================================*
+ * toBase45
+ *==========================================================================*/
+
+static
+void
+test_toBase45(
+ void)
+{
+ g_assert(HarbourBase45::toBase45(QByteArray()).isEmpty());
+ // Examples from draft-faltstrom-base45-07
+ g_assert(HarbourBase45::toBase45(QByteArray("AB")) == QString("BB8"));
+ g_assert(HarbourBase45::toBase45(QByteArray("Hello!!")) == QString("%69 VD92EX0"));
+ g_assert(HarbourBase45::toBase45(QByteArray("base-45")) == QString("UJCLQE7W581"));
+}
+
+/*==========================================================================*
+ * fromBase45
+ *==========================================================================*/
+
+static
+void
+test_fromBase45(
+ void)
+{
+ // Invalid
+ g_assert(HarbourBase45::fromBase45(QByteArray("AA[")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A[A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("[AA")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("AA(")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A(A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("(AA")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A(")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A[")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("[A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("ZZ")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("ZZZ")).isEmpty());
+ // Valid
+ g_assert(HarbourBase45::fromBase45(QByteArray()).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("BB8")) == QByteArray("AB"));
+ g_assert(HarbourBase45::fromBase45(QByteArray("%69 VD92EX0")) == QByteArray("Hello!!"));
+ g_assert(HarbourBase45::fromBase45(QByteArray("UJCLQE7W581")) == QByteArray("base-45"));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourBase45/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("isValidBase45"), test_isValidBase45);
+ g_test_add_func(TEST_("fromBase45"), test_fromBase45);
+ g_test_add_func(TEST_("toBase45"), test_toBase45);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/coverage/.gitignore
^
|
@@ -0,0 +1,4 @@
+app.gcov
+full.gcov
+report
+*~
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-mybackup-1.0.6.tar.gz/harbour-lib/test/coverage/run
^
|
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# This script requires lcov, dirname
+#
+
+TESTS="\
+TestHarbourBase32 \
+TestHarbourBase45"
+
+function err() {
+ echo "*** ERROR!" $1
+ exit 1
+}
+
+# Check the required tools
+which lcov >> /dev/null || err "Please install lcov"
+which dirname >> /dev/null || err "Please install dirname"
+
+# LCOV 1.10 has branch coverage disabled per default
+# Previous versions didn't have the --rc option
+if [ ! -z "$(lcov --help | grep ' --rc ')" ] ; then
+ LCOV_OPT="--rc lcov_branch_coverage=1"
+ GENHTML_OPT="--branch-coverage"
+fi
+
+pushd `dirname $0` > /dev/null
+COV_DIR="$PWD"
+pushd .. > /dev/null
+TEST_DIR="$PWD"
+pushd .. > /dev/null
+TOP_DIR="$PWD"
+popd > /dev/null
+popd > /dev/null
+popd > /dev/null
+
+FULL_COV="$COV_DIR/full.gcov"
+APP_COV="$COV_DIR/app.gcov"
+
+make -C "$TEST_DIR" clean
+rm -f "$FULL_COV" "$APP_COV"
+TESTS_COV=
+
+for t in $TESTS ; do
+ pushd "$TEST_DIR/$t"
+ make -C "$TEST_DIR/$t" clean coverage || exit 1
+ build/coverage/$t || exit 1
+ TEST_COV="$TEST_DIR/$t/build/coverage/$t.cov"
+ lcov $LCOV_OPT -c -d build/coverage -o "$TEST_COV" || exit 1
+ TESTS_COV+="-a $TEST_COV "
+ popd
+done
+
+lcov $LCOV_OPT $TESTS_COV -o "$FULL_COV" || exit 1
+lcov $LCOV_OPT -e "$FULL_COV" "$TOP_DIR/src/*" -o "$APP_COV" || exit 1
+genhtml $GENHTML_OPT "$APP_COV" -t "HarbourLib" --output-directory "$COV_DIR/report" || exit 1
|