[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://git.monich.net/git/sailfish-qrshare.git</param>
<param name="branch">master</param>
- <param name="revision">ce91ffb</param>
+ <param name="revision">e17035d</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Deleted |
_service:tar_git:sailfish-qrshare-1.0.8+master.20200103140108.1.gce91ffb.tar.gz/shareplugin/src/librpm.c
^
|
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava@monich.com>
- *
- * You may use this file under the terms of 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 <rpm/rpmlib.h>
-#include <rpm/header.h>
-#include <rpm/rpmts.h>
-#include <rpm/rpmdb.h>
-
-#include <dlfcn.h>
-
-#define LIBRPM_FUNCTIONS(f) \
- f(rpmts, rpmtsCreate, (void), (), 0) \
- f(rpmdbMatchIterator, rpmtsInitIterator, \
- (const rpmts ts, rpmDbiTagVal rpmtag, const void * keyp, size_t keylen), \
- (ts, rpmtag, keyp, keylen), NULL) \
- f(Header, rpmdbNextIterator, (rpmdbMatchIterator mi), (mi), NULL) \
- f(const char *, headerGetString, (Header h, rpmTagVal tag), \
- (h, tag), NULL) \
- f(rpmdbMatchIterator, rpmdbFreeIterator, (rpmdbMatchIterator mi), \
- (mi), NULL) \
- f(rpmts, rpmtsFree, (rpmts ts), (ts), 0)
-
-/*
- * We only need to determine transfer-engine version on old releases of
- * Sailfish OS, so if librpm.so.2 isn't there (and it's not there on
- * newer releases), we just assume the new plugin API and don't really
- * need to know the exact transfer-engine version (until API changes again)
- */
-#define LIBRPM_SO "/usr/lib/librpm.so.8"
-#define LIBRPM_NUM_FUNCTIONS (sizeof(librpm_names)/sizeof(librpm_names[0]))
-#define LIBRPM_NO_HANDLE ((void*)-1)
-
-static const char* librpm_names[] = {
- "rpmReadConfigFiles",
- #define FN_NAME(type,name,params,args,fail) #name,
- LIBRPM_FUNCTIONS(FN_NAME)
-};
-
-static struct {
- void* handle;
- union {
- struct librpm_proc {
- int (*rpmReadConfigFiles)(const char* file, const char* target);
- #define FN_POINTER(type,name,params,args,fail) type (* name) params;
- LIBRPM_FUNCTIONS(FN_POINTER)
- } librpm;
- void* entry[LIBRPM_NUM_FUNCTIONS];
- } fn;
-} librpm;
-
-/* rpmReadConfigFiles() is the special function where we load the library */
-int rpmReadConfigFiles(const char* file, const char* target)
-{
- if (!librpm.handle) {
- librpm.handle = dlopen(LIBRPM_SO, RTLD_LAZY);
- if (librpm.handle) {
- unsigned int i;
- for (i=0; i<LIBRPM_NUM_FUNCTIONS; i++) {
- librpm.fn.entry[i] = dlsym(librpm.handle, librpm_names[i]);
- }
- } else {
- librpm.handle = LIBRPM_NO_HANDLE;
- }
- }
- return librpm.fn.librpm.rpmReadConfigFiles ?
- librpm.fn.librpm.rpmReadConfigFiles(file, target) :
- -1;
-}
-
-/* All other wrappers are generated by the preprocessor */
-#define FN_IMPL(type,name,params,args,fail) type name params \
- { return librpm.fn.librpm.name ? librpm.fn.librpm.name args : fail; }
-LIBRPM_FUNCTIONS(FN_IMPL)
|
[-]
[+]
|
Deleted |
_service:tar_git:sailfish-qrshare-1.0.8+master.20200103140108.1.gce91ffb.tar.gz/shareplugin/transferengine/transfermethodinfo1.h
^
|
@@ -1,23 +0,0 @@
-#ifndef TRANSFERMETHODINFO_H
-#define TRANSFERMETHODINFO_H
-
-#include <QString>
-#include <QStringList>
-
-// Version < 0.2.0
-class TransferMethodInfo {
-public:
- TransferMethodInfo();
- TransferMethodInfo &operator=(const TransferMethodInfo &other);
- TransferMethodInfo(const TransferMethodInfo &other);
- ~TransferMethodInfo();
-
- QString displayName;
- QString userName;
- QString methodId;
- QString shareUIPath;
- QStringList capabilitities;
- quint32 accountId;
-};
-
-#endif // TRANSFERMETHODINFO_H
|
[-]
[+]
|
Deleted |
_service:tar_git:sailfish-qrshare-1.0.8+master.20200103140108.1.gce91ffb.tar.gz/shareplugin/transferengine/transfermethodinfo2.h
^
|
@@ -1,26 +0,0 @@
-#ifndef TRANSFERMETHODINFO_H
-#define TRANSFERMETHODINFO_H
-
-#include <QString>
-#include <QStringList>
-#include <QVariantHash>
-
-// Version >= 0.2.0
-class TransferMethodInfo {
-public:
- TransferMethodInfo();
- TransferMethodInfo &operator=(const TransferMethodInfo &other);
- TransferMethodInfo(const TransferMethodInfo &other);
- ~TransferMethodInfo();
-
- QString displayName;
- QString userName;
- QString methodId;
- QString shareUIPath;
- QStringList capabilitities;
- quint32 accountId;
- QString accountIcon;
- QVariantHash hints;
-};
-
-#endif // TRANSFERMETHODINFO_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/config.pri
^
|
@@ -0,0 +1,5 @@
+# These must be under /usr/share/nemo-transferengine to allow access
+# from sandboxed apps
+QRSHARE_UI_DIR = /usr/share/nemo-transferengine/openrepos-qrshare
+QRSHARE_TRANSLATIONS_DIR = $${QRSHARE_UI_DIR}/translations
+QRSHARE_TRANSLATIONS_FILE = sailfish-qrshare
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/mkicon/mkicon.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -36,24 +36,26 @@
#include <QImage>
#include <QPainter>
#include <QSvgRenderer>
-#include <QGuiApplication>
#include <QDebug>
#ifdef HAVE_SILICA
# include <silicatheme.h>
#else
# include <dlfcn.h>
-# define SILICA_SO "/usr/lib/libsailfishsilica.so.1"
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+
+# define SILICA_SO LIBDIR "/libsailfishsilica.so.1"
typedef QObject* (*SilicaInstanceFunc)(void);
typedef qreal (*SilicaIconSizeMediumFunc)(QObject*);
-#endif
+#endif // HAVE_SILICA
// Converts SVGs to PNGs of the size Theme.iconSizeMedium
int main(int argc, char* argv[])
{
- setenv("QT_QPA_PLATFORM", "minimal", 1);
- QGuiApplication app(argc, argv);
-
#ifdef HAVE_SILICA
const int size = Silica::Theme::instance()->iconSizeMedium();
#else
@@ -95,7 +97,7 @@
qWarning() << "Failed to save" << qPrintable(file);
}
} else {
- qWarning() << "Not a valid DVG file:" << qPrintable(file);
+ qWarning() << "Not a valid SVG file:" << qPrintable(file);
}
}
return 0;
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/LICENSE
^
|
@@ -1,5 +1,5 @@
-Copyright (C) 2015-2019 Jolla Ltd.
-Copyright (C) 2015-2019 Slava Monich <slava@monich.com>
+Copyright (C) 2015-2021 Jolla Ltd.
+Copyright (C) 2015-2021 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/README
^
|
@@ -3,7 +3,7 @@
Some of them allow to access undocumented Sailfish OS features, some
provide compatibility with older releases of Sailfish OS. This code
-has been tested agaist Sailfish OS 2.0 meaning that most of it is
+has been tested against Sailfish OS 2.0 meaning that most of it is
probably incompatible with older versions.
The easiest way to use this code in your project is to add this repo
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/harbour-lib.pro
^
|
@@ -4,6 +4,10 @@
QT += dbus
QT-= gui
+# For HarbourSystemTime
+CONFIG += link_pkgconfig
+PKGCONFIG += libglibutil
+
VERSION = 1.0
greaterThan(QT_MAJOR_VERSION, 4) {
@@ -20,16 +24,24 @@
SOURCES += \
src/HarbourBase32.cpp \
+ src/HarbourBase45.cpp \
src/HarbourClipboard.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 \
+ src/HarbourSystem.cpp \
+ src/HarbourSystemInfo.cpp \
src/HarbourSystemState.cpp \
+ src/HarbourSystemTime.cpp \
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
@@ -45,16 +57,24 @@
INCLUDEPATH += include
PUBLIC_HEADERS += \
include/HarbourBase32.h \
+ include/HarbourBase45.h \
include/HarbourClipboard.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 \
+ include/HarbourSystem.h \
+ include/HarbourSystemInfo.h \
include/HarbourSystemState.h \
+ include/HarbourSystemTime.h \
include/HarbourTask.h \
include/HarbourTemporaryFile.h \
include/HarbourTransferMethodInfo.h \
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourJson.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2020 Jolla Ltd.
+ * Copyright (C) 2015-2020 Slava Monich <slava@monich.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 Nemo Mobile 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_JSON_H
@@ -38,8 +42,8 @@
#include <QVariant>
namespace HarbourJson {
- bool save(QString aPath, const QVariantMap& aMap);
- bool load(QString aPath, QVariantMap& aRoot);
+ bool save(const QString& aPath, const QVariantMap& aMap);
+ bool load(const QString& aPath, QVariantMap& aRoot);
}
#endif // HARBOUR_JSON_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourMediaPlugin.h
^
|
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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_MEDIA_PLUGIN_H
+#define HARBOUR_MEDIA_PLUGIN_H
+
+#include "HarbourPluginLoader.h"
+
+// Workaround for org.nemomobile.policy (or Sailfish.Media) not being
+// allowed in harbour apps
+
+class HarbourMediaPlugin : public HarbourPluginLoader
+{
+ static HarbourMediaPlugin* gInstance;
+ static const char MEDIAKEY_QML_TYPE[];
+
+public:
+ static void registerTypes(QQmlEngine* aEngine, const char* aModule,
+ int aMajor, int aMinor);
+
+private:
+ HarbourMediaPlugin(QQmlEngine* aEngine);
+ ~HarbourMediaPlugin();
+ void registerTypes(const char* aModule, int aMajor, int aMinor);
+};
+
+#endif // HARBOUR_MEDIA_PLUGIN_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourPluginLoader.h
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2017 Jolla Ltd.
- * Copyright (C) 2017 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
*
- * You may use this file under the terms of BSD license as follows:
+ * 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
@@ -11,23 +11,24 @@
* 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 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.
+ * 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.
+ * 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.
*/
#ifndef HARBOUR_PLUGIN_LOADER_H
@@ -79,6 +80,7 @@
const char* aModule, int aMajor, int aMinor);
private:
+ class LibQt5Qml;
class Private;
Private* iPrivate;
};
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourPolicyPlugin.h
^
|
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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_POLICY_PLUGIN_H
+#define HARBOUR_POLICY_PLUGIN_H
+
+#include "HarbourPluginLoader.h"
+
+// Workaround for org.nemomobile.policy (or Nemo.Policy) not being
+// allowed in harbour apps
+
+class HarbourPolicyPlugin : public HarbourPluginLoader
+{
+ static HarbourPolicyPlugin* gInstance;
+ static const char RESOURCE_QML_TYPE[];
+ static const char PERMISSIONS_QML_TYPE[];
+
+public:
+ static void registerTypes(QQmlEngine* aEngine, const char* aModule,
+ int aMajor, int aMinor);
+
+private:
+ HarbourPolicyPlugin(QQmlEngine* aEngine);
+ ~HarbourPolicyPlugin();
+ void registerTypes(const char* aModule, int aMajor, int aMinor);
+};
+
+#endif // HARBOUR_POLICY_PLUGIN_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourProcessState.h
^
|
@@ -0,0 +1,57 @@
+/*
+ * 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)
+
+public:
+ explicit HarbourProcessState(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourProcessState>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ static bool isJailedApp();
+};
+
+#endif // HARBOUR_PROCESS_STATE_H
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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();
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourSystem.h
^
|
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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_SYSTEM_H
+#define HARBOUR_SYSTEM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* HarbourDlopen(const char* aLibFile, int aFlags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HARBOUR_SYSTEM_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourSystemInfo.h
^
|
@@ -0,0 +1,76 @@
+/*
+ * 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:
+ *
+ * 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_SYSTEM_INFO_H
+#define HARBOUR_SYSTEM_INFO_H
+
+#include <QObject>
+#include <QVector>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourSystemInfo: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourSystemInfo)
+ Q_PROPERTY(QString osName READ osName CONSTANT)
+ Q_PROPERTY(QString osVersion READ osVersion CONSTANT)
+
+public:
+ explicit HarbourSystemInfo(QObject* aParent = NULL);
+ ~HarbourSystemInfo();
+
+ // Callback for qmlRegisterSingletonType<HarbourSystemInfo>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ 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:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SYSTEM_INFO_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourSystemTime.h
^
|
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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_SYSTEM_TIME_H
+#define HARBOUR_SYSTEM_TIME_H
+
+#include <QObject>
+#include <QSharedPointer>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourSystemTime: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourSystemTime)
+ Q_PROPERTY(QString notification READ emptyString NOTIFY notify)
+
+public:
+ explicit HarbourSystemTime(QObject* aParent = NULL);
+ ~HarbourSystemTime();
+
+ // Dummy getter for notification property which can be used to
+ // force re-evaluation of a JavaScript expression. As its name
+ // suggests, always returns empty string.
+ static QString emptyString();
+
+ // Callback for qmlRegisterSingletonType<HarbourSystemTime>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ // Shared instance for use by native code
+ static QSharedPointer<HarbourSystemTime> sharedInstance();
+
+Q_SIGNALS:
+ // Recipient must be ready to receive multiple notifications for
+ // a single time or timezone change.
+ void preNotify(); // For Date.timeZoneUpdated()
+ void notify(); // For everything else
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SYSTEM_TIME_H
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourTask.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,24 +11,28 @@
* 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 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.
+ * 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_TASK_H
@@ -47,7 +51,7 @@
Q_OBJECT
protected:
- HarbourTask(QThreadPool* aPool, QThread* aTargetThread = NULL);
+ HarbourTask(QThreadPool* aPool, QThread* aTargetThread = Q_NULLPTR);
public:
virtual ~HarbourTask();
@@ -64,7 +68,7 @@
void released();
protected:
- virtual void run();
+ void run() Q_DECL_OVERRIDE;
virtual void performTask() = 0;
Q_SIGNALS:
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -81,6 +81,9 @@
qreal opacityHigh() const;
qreal opacityOverlay() const;
+ Q_INVOKABLE static QColor invertedColor(const QColor& aColor);
+ Q_INVOKABLE static qreal colorDifference(const QColor& aColor1, const QColor& aColor2);
+
Q_SIGNALS:
void colorSchemeChanged();
void primaryColorChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/include/HarbourTransferMethodsModel.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2019 Jolla Ltd.
- * Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2020 Jolla Ltd.
+ * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -22,7 +22,7 @@
* "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
@@ -37,7 +37,6 @@
#include "HarbourTransferMethodInfo.h"
#include <QLocale>
-#include <QRegExp>
class QTranslator;
class QQmlEngine;
@@ -49,17 +48,8 @@
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
Q_PROPERTY(bool accountIconSupported READ accountIconSupported NOTIFY accountIconSupportedChanged)
- typedef QDBusPendingCallWatcher* (HarbourTransferMethodsModel::*RequestUpdate)();
-
-public:
- enum TransferMethodsRole {
- DisplayNameRole = Qt::UserRole + 1,
- UserNameRole,
- MethodIdRole,
- ShareUIPathRole,
- AccountIdRole,
- AccountIconRole
- };
+ Q_PROPERTY(bool showAccountsPending READ showAccountsPending NOTIFY showAccountsPendingChanged)
+ Q_PROPERTY(bool canShowAccounts READ canShowAccounts NOTIFY canShowAccountsChanged)
public:
explicit HarbourTransferMethodsModel(QObject* aParent = Q_NULLPTR);
@@ -74,39 +64,27 @@
QString filter() const;
void setFilter(QString filter);
bool accountIconSupported() const;
+ bool showAccountsPending() const;
+ bool canShowAccounts() const;
+
+ Q_INVOKABLE void showAccounts();
+ // 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;
-private:
- void filterModel();
- static QRegExp regExp(QString aRegExp);
- QDBusPendingCallWatcher* checkTransferMethods();
- QDBusPendingCallWatcher* requestTransferMethods();
- QDBusPendingCallWatcher* requestTransferMethods2();
- void setTransferMethods2(HarbourTransferMethodInfo2List aList);
-
-private Q_SLOTS:
- void onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch);
- void onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch);
- void onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch);
- void requestUpdate();
-
Q_SIGNALS:
void countChanged();
void filterChanged();
void accountIconSupportedChanged();
+ void showAccountsPendingChanged();
+ void canShowAccountsChanged();
private:
+ class Private;
class TransferEngine;
- TransferEngine* iTransferEngine;
- QString iFilter;
- QList<HarbourTransferMethodInfo2> iMethodList;
- QList<int> iFilteredList;
- bool iAccountIconSupported;
- RequestUpdate iRequestUpdate;
- QDBusPendingCallWatcher* iUpdateWatcher;
+ Private* iPrivate;
};
#endif // HARBOUR_TRANSFER_METHODS_MODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourFitLabel.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 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,7 +39,7 @@
property int maxFontSize: Theme.fontSizeMedium
property real maxWidth: width
property real maxHeight: height
- property int refitting
+ property bool refitting
smooth: true
visible: opacity > 0
@@ -50,7 +50,12 @@
Behavior on opacity { FadeAnimation {} }
- Component.onCompleted: refitText()
+ Component.onCompleted: {
+ refitting = true
+ font.pixelSize = maxFontSize
+ refitTextRun()
+ refitting = false
+ }
onMaxWidthChanged: refitText()
onMaxHeightChanged: refitText()
@@ -59,21 +64,25 @@
onMinFontSizeChanged: refitText()
function refitText() {
- refitting++
- if (refitting == 1 && implicitHeight > 0 && implicitWidth > 0) {
+ if (!refitting) {
+ refitting = true
+ refitTextRun()
+ refitting = false
+ }
+ }
+
+ function refitTextRun() {
+ if (implicitHeight > 0 && implicitWidth > 0) {
if (font.pixelSize % 2) font.pixelSize++
- while (implicitWidth > maxWidth || implicitHeight > maxHeight) {
- if ((font.pixelSize -= 2) <= minFontSize)
- break
+ while ((implicitWidth > maxWidth || implicitHeight > maxHeight || font.pixelSize > maxFontSize) && (font.pixelSize - 2) >= minFontSize) {
+ font.pixelSize -= 2
}
- while (implicitWidth < maxWidth && implicitHeight < maxHeight) {
+ while (implicitWidth < maxWidth && implicitHeight < maxHeight && (font.pixelSize + 2) <= maxFontSize) {
font.pixelSize += 2
}
- font.pixelSize -= 2
- if (font.pixelSize >= maxFontSize) {
- font.pixelSize = maxFontSize
+ if (implicitWidth > maxWidth || implicitHeight > maxHeight) {
+ font.pixelSize -= 2
}
}
- refitting--
}
}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourGrayscaleEffect.qml
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+ShaderEffect {
+ property variant source
+
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 coord;
+ void main() {
+ coord = qt_MultiTexCoord0;
+ gl_Position = qt_Matrix * qt_Vertex;
+ }"
+ fragmentShader: "
+ varying highp vec2 coord;
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ void main() {
+ lowp vec4 tex = texture2D(source, coord);
+ gl_FragColor = vec4(vec3(dot(tex.rgb,
+ vec3(0.344, 0.5, 0.156))),
+ tex.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourHighlightIcon.qml
^
|
@@ -0,0 +1,38 @@
+// This is basically a Qt example slightly adapted for Sailfish OS
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Image {
+ id: icon
+
+ property bool highlightEnabled: true
+ property color highlightColor: Theme.highlightColor
+
+ layer.enabled: highlightEnabled
+ layer.effect: ShaderEffect {
+ property variant src: icon
+ property color highlight: highlightColor
+
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 coord;
+ void main() {
+ coord = qt_MultiTexCoord0;
+ gl_Position = qt_Matrix * qt_Vertex;
+ }"
+ fragmentShader: "
+ varying highp vec2 coord;
+ uniform sampler2D src;
+ uniform lowp vec4 highlight;
+ uniform lowp float qt_Opacity;
+ void main() {
+ lowp vec4 tex = texture2D(src, coord);
+ gl_FragColor = vec4(vec3(dot(tex.rgb,
+ vec3(0.344, 0.5, 0.156))),
+ tex.a) * qt_Opacity * highlight;
+ }"
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourHintIconButton.qml
^
|
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+MouseArea {
+ property alias icon: image
+ property bool down: pressed && containsMouse
+ property bool highlighted: down
+ property string hint
+
+ signal showHint(var text)
+ signal hideHint()
+
+ width: Theme.itemSizeSmall
+ height: Theme.itemSizeSmall
+
+ readonly property bool _showPress: highlighted || pressTimer.running
+
+ onPressedChanged: {
+ if (pressed) {
+ pressTimer.start()
+ }
+ }
+
+ onClicked: hideHint()
+
+ onReleased: hideHint()
+
+ onPressAndHold: if (hint !== "") showHint(hint)
+
+ onCanceled: {
+ pressTimer.stop()
+ hideHint()
+ }
+
+ Timer {
+ id: pressTimer
+
+ interval: 50
+ }
+
+ HarbourHighlightIcon {
+ id: image
+
+ highlightColor: _showPress ? Theme.highlightColor : Theme.primaryColor
+ sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
+ anchors.centerIn: parent
+ opacity: parent.enabled ? 1.0 : 0.4
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourHorizontalSwipeHint.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -40,15 +40,20 @@
anchors.fill: parent
property bool swipeRight
+ property bool bothWays
property bool hintEnabled
property alias text: label.text
property alias hintDelay: hintDelayTimer.interval
+ property alias loops: touchInteractionHint.loops
readonly property bool hintRunning: hintDelayTimer.running || touchInteractionHint.running || label.opacity > 0
signal hintShown()
function showHint() {
- touchInteractionHint.start()
+ if (!touchInteractionHint.running) {
+ touchInteractionHint.direction = touchInteractionHint.defaultDirection
+ touchInteractionHint.start()
+ }
}
onHintEnabledChanged: {
@@ -72,9 +77,19 @@
TouchInteractionHint {
id: touchInteractionHint
- direction: swipeRight ? TouchInteraction.Right : TouchInteraction.Left
+ readonly property int defaultDirection: swipeRight ? TouchInteraction.Right : TouchInteraction.Left
+ readonly property int otherDirection: swipeRight ? TouchInteraction.Left : TouchInteraction.Right
anchors.verticalCenter: parent.verticalCenter
- onRunningChanged: if (!running) hint.hintShown()
+ onRunningChanged: {
+ if (!running) {
+ if (bothWays && direction === defaultDirection) {
+ direction = otherDirection
+ start()
+ } else {
+ hint.hintShown()
+ }
+ }
+ }
}
Timer {
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourIconTextButton.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 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
@@ -38,7 +38,7 @@
property alias icon: image
property bool down: pressed && containsMouse
property bool highlighted: down
- property alias iconSource: image.imageSource
+ property alias iconSource: image.source
property alias text: label.text
readonly property bool _showPress: highlighted || pressTimer.running
@@ -54,25 +54,11 @@
width: Math.max(image.width, label.width)
height: image.height + label.height
- Image {
+ HarbourHighlightIcon {
id: image
- readonly property color highlightColor: Theme.highlightColor
- property url imageSource
- property string highlightSource: {
- if (source != "") {
- var tmpSource = image.source.toString()
- var index = tmpSource.lastIndexOf("?")
- if (index !== -1) {
- tmpSource = tmpSource.substring(0, index)
- }
- return tmpSource + "?" + highlightColor
- } else {
- return ""
- }
- }
+ highlightColor: _showPress ? Theme.highlightColor : Theme.primaryColor
sourceSize: Qt.size(Theme.itemSizeSmall, Theme.itemSizeSmall)
- source: _showPress ? highlightSource : imageSource
opacity: parent.enabled ? 1.0 : 0.4
anchors {
top: parent.top
@@ -91,7 +77,7 @@
}
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeExtraSmall
- color: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ color: _showPress ? Theme.secondaryHighlightColor : Theme.secondaryColor
}
Timer {
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:
*
@@ -47,10 +47,7 @@
textRightMargin: textMargin
echoMode: _usePasswordEchoMode ? passwordEchoMode : TextInput.Normal
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
-
- //: Default placeholder for password field
- //% "Password"
- placeholderText: qsTrId("components-ph-password")
+ placeholderText: label
//: Default label for password field
//% "Password"
@@ -67,6 +64,7 @@
onActiveChanged: {
if (!Qt.application.active) {
_usePasswordEchoMode = true
+ if (!readOnly) text = "" // Reset whatever has been typed
}
}
}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourPressEffect.qml
^
|
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+ShaderEffect {
+ property variant source
+ property color color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec4 color;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(void) {
+ highp vec4 pixelColor = texture2D(source, qt_TexCoord0);
+ gl_FragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625),
+ color.rgb/max(color.a, 0.00390625), color.a) *
+ pixelColor.a, pixelColor.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourShareMethodList.qml
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+SilicaListView {
+ id: view
+
+ property url source
+ property string subject
+ property string emailTo
+ property string type
+
+ width: parent.width
+ height: Theme.itemSizeSmall * model.count
+
+ property string addAccountText: "Add account"
+ readonly property bool accountIconSupported: model.accountIconSupported
+ property var content: []
+ // model: HarbourTransferMethodsModel
+
+ onTypeChanged: content.type = type
+
+ Component.onCompleted: content.type = type
+
+ delegate: BackgroundItem {
+ id: backgroundItem
+ width: view.width
+
+ Image {
+ id: icon
+
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: accountIcon ? accountIcon :
+ view.accountIconSupported ? "image://theme/icon-m-share" : ""
+ visible: view.accountIconSupported
+ }
+
+ Label {
+ id: displayNameLabel
+
+ text: displayName
+ color: backgroundItem.highlighted ? Theme.highlightColor : Theme.primaryColor
+ truncationMode: TruncationMode.Fade
+ x: Theme.horizontalPageMargin
+ anchors {
+ left: icon.visible ? icon.right : parent.left
+ leftMargin: icon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ width: Math.min(implicitWidth, parent.width - 2*Theme.horizontalPageMargin)
+ }
+
+ Label {
+ text: userName
+ font.pixelSize: Theme.fontSizeMedium
+ color: backgroundItem.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ truncationMode: TruncationMode.Fade
+ anchors {
+ left: displayNameLabel.right
+ leftMargin: Theme.paddingSmall
+ right: parent.right
+ rightMargin: Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ visible: text.length > 0
+ }
+
+ onClicked: {
+ pageStack.push(model.shareUIPath, {
+ source: view.source,
+ content: content,
+ methodId: model.methodId,
+ displayName: model.displayName,
+ accountId: model.accountId,
+ accountName: model.userName,
+ emailTo: view.emailTo,
+ emailSubject: view.subject
+ })
+ }
+ }
+
+ footer: BackgroundItem {
+ enabled: model.canShowAccounts && !model.showAccountsPending
+ opacity: enabled ? 1.0 : 0.4
+
+ Image {
+ id: addAccountIcon
+
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: view.accountIconSupported ?
+ ("image://theme/icon-m-add" + (parent.highlighted ? "?" + Theme.highlightColor : "")) : ""
+ visible: view.accountIconSupported
+ }
+
+ Label {
+ text: addAccountText
+ x: Theme.horizontalPageMargin
+ anchors {
+ left: addAccountIcon.visible ? addAccountIcon.right : parent.left
+ leftMargin: addAccountIcon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ color: highlighted ? Theme.highlightColor : Theme.primaryColor
+ }
+
+ onClicked: model.showAccounts()
+ }
+
+ VerticalScrollDecorator { }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/qml/HarbourTextFlip.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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:
*
@@ -39,12 +39,15 @@
property string text
property Item target
property real duration: 500
+ property bool enabled: true
+ property string property: "text"
+ readonly property bool running: animation.running
property var animation: SequentialAnimation {
alwaysRunToEnd: true
onRunningChanged: {
- if (!running && target.text !== rotation.text) {
+ if (!running && target[property] != rotation.text) {
start()
}
}
@@ -57,7 +60,7 @@
to: 90
duration: rotation.duration/2
}
- ScriptAction { script: target.text = rotation.text; }
+ ScriptAction { script: target[property] = rotation.text; }
NumberAnimation {
easing.type: Easing.InOutSine
target: rotation
@@ -78,5 +81,23 @@
z: 0
}
- onTextChanged: animation.start()
+ function flipTo(value) {
+ if (!!target) {
+ animation.start()
+ text = value
+ }
+ }
+
+ function _updateTargetProperty() {
+ if (!!target) {
+ if (enabled) {
+ animation.start()
+ } else if (!animation.running) {
+ target[property] = text
+ }
+ }
+ }
+
+ onTextChanged: _updateTargetProperty()
+ onTargetChanged: _updateTargetProperty()
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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;
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourJson.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2020 Jolla Ltd.
+ * Copyright (C) 2015-2020 Slava Monich <slava@monich.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 Nemo Mobile 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 "HarbourJson.h"
@@ -46,35 +50,64 @@
# include <qjson/serializer.h>
#endif
-bool HarbourJson::save(QString aPath, const QVariantMap& aMap)
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+bool HarbourJson::save(const QString& aPath, const QVariantMap& aMap)
{
QFileInfo file(aPath);
QDir dir(file.dir());
if (dir.mkpath(dir.absolutePath())) {
- QFile f(file.absoluteFilePath());
+ const QString absPath(file.absoluteFilePath());
+ QFile f(absPath);
if (!aMap.isEmpty()) {
+ struct stat st;
+ const QByteArray pathBytes(absPath.toLocal8Bit());
+ const char* path = pathBytes.constData();
+ const bool haveFileAttr = (stat(path, &st) == 0);
+
if (f.open(QIODevice::WriteOnly)) {
+ bool ok;
#if QT_VERSION >= 0x050000
if (f.write(QJsonDocument::fromVariant(aMap).toJson()) >= 0) {
- return true;
+ ok = true;
+ } else {
+ HWARN("Error writing" << absPath << f.errorString());
}
#else
QJson::Serializer serializer;
QByteArray json = serializer.serialize(aMap);
if (!json.isNull()) {
- if (f.write(json ) >= 0) {
- return true;
+ if (f.write(json) >= 0) {
+ ok = true;
+ } else {
+ HWARN("Error writing" << absPath << f.errorString());
}
} else {
HWARN("Json serialization error");
}
#endif
- HWARN("Error writing" << aPath << f.errorString());
+ if (ok) {
+ if (haveFileAttr) {
+ // Try to restore ownership and mode
+ if (chown(path, st.st_uid, st.st_gid)) {
+ HWARN("Failed to chown" << path << ":" <<
+ strerror(errno));
+ }
+ if (chmod(path, st.st_mode & ~S_IFMT)) {
+ HWARN("Failed to chmod" << path << ":" <<
+ strerror(errno));
+ }
+ }
+ return true;
+ }
} else {
- HWARN("Error opening" << aPath << f.errorString());
+ HWARN("Error opening" << absPath << f.errorString());
}
} else if (!f.remove()) {
- HWARN("Error removing" << aPath << f.errorString());
+ HWARN("Error removing" << absPath << f.errorString());
}
} else {
HWARN("Failed to create" << dir.absolutePath());
@@ -82,7 +115,7 @@
return false;
}
-bool HarbourJson::load(QString aPath, QVariantMap& aRoot)
+bool HarbourJson::load(const QString& aPath, QVariantMap& aRoot)
{
QFile f(aPath);
if (f.exists()) {
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourMediaPlugin.cpp
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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 "HarbourMediaPlugin.h"
+#include "HarbourDebug.h"
+
+// Workaround for org.nemomobile.policy (or Sailfish.Media) not being
+// allowed in harbour apps
+
+HarbourMediaPlugin* HarbourMediaPlugin::gInstance = Q_NULLPTR;
+
+const char HarbourMediaPlugin::MEDIAKEY_QML_TYPE[] = "MediaKey";
+
+HarbourMediaPlugin::HarbourMediaPlugin(
+ QQmlEngine* aEngine) :
+ HarbourPluginLoader(aEngine, "Sailfish.Media", 1, 0)
+{
+}
+
+HarbourMediaPlugin::~HarbourMediaPlugin()
+{
+ HASSERT(gInstance == this);
+ gInstance = Q_NULLPTR;
+}
+
+void
+HarbourMediaPlugin::registerTypes(
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ reRegisterType(MEDIAKEY_QML_TYPE, aModule, aMajor, aMinor);
+}
+
+void
+HarbourMediaPlugin::registerTypes(
+ QQmlEngine* aEngine,
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ if (!gInstance) {
+ gInstance = new HarbourMediaPlugin(aEngine);
+ }
+ gInstance->registerTypes(aModule, aMajor, aMinor);
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017 Jolla Ltd.
- * Copyright (C) 2017 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,26 +11,28 @@
* 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 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.
+ * 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.
+ * 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.
*/
#include "HarbourPluginLoader.h"
+#include "HarbourSystem.h"
#include "HarbourDebug.h"
// These are included from qqmlengine.h
@@ -72,7 +74,7 @@
// _ZNK8QQmlType22attachedPropertiesTypeEP17QQmlEnginePrivate
//
-#define LIBQT5QML_SO "/usr/lib/libQt5Qml.so.5"
+#define LIBQT5QML_SO "libQt5Qml.so.5"
// sym,ret,name,args
#define QMLTYPE_FUNCTIONS(f) \
@@ -124,13 +126,45 @@
Q_STATIC_ASSERT(sizeof(QmlTypeFunctions) == NUM_FUNCTIONS*sizeof(void*));
// ==========================================================================
+// HarbourPluginLoader::LibQt5Qml
+// ==========================================================================
+
+class HarbourPluginLoader::LibQt5Qml {
+public:
+
+ LibQt5Qml();
+
+public:
+ void* iHandle;
+ union {
+ QmlTypeFunctions fn;
+ void* ptr[NUM_FUNCTIONS];
+ } iSym;
+};
+
+HarbourPluginLoader::LibQt5Qml::LibQt5Qml() :
+ iHandle(HarbourDlopen(LIBQT5QML_SO, RTLD_LAZY))
+{
+ memset(&iSym, 0, sizeof(iSym));
+ if (iHandle) {
+ // Resolve unstable symbols
+ for (uint i = 0; i < NUM_FUNCTIONS; i++) {
+ iSym.ptr[i] = dlsym(iHandle, QmlTypeSymbols[i]);
+ HDEBUG(QmlTypeSymbols[i] << (iSym.ptr[i] ? "OK" : "missing"));
+ }
+ // No need to ever call dlclose(iHandle);
+ } else {
+ HWARN("Failed to load" << LIBQT5QML_SO);
+ }
+}
+
+// ==========================================================================
// HarbourPluginLoader::Private
// ==========================================================================
class HarbourPluginLoader::Private {
public:
Private(QQmlEngine* aEngine, QString aModule, int aMajor, int aMinor);
- ~Private();
QQmlType* qmlType(QString aName);
@@ -142,18 +176,18 @@
const char* aModule, int aMajor, int aMinor);
public:
+ static const LibQt5Qml gLibQt5Qml;
+
+public:
QQmlEngine* iEngine;
QString iModule;
int iMajor;
int iMinor;
bool iLoaded;
- void* iHandle;
- union {
- QmlTypeFunctions fn;
- void* ptr[NUM_FUNCTIONS];
- } iLibQt5Qml;
};
+const HarbourPluginLoader::LibQt5Qml HarbourPluginLoader::Private::gLibQt5Qml;
+
HarbourPluginLoader::Private::Private(
QQmlEngine* aEngine,
QString aModule,
@@ -163,37 +197,21 @@
iModule(aModule),
iMajor(aMajor),
iMinor(aMinor),
- iLoaded(false),
- iHandle(NULL)
+ iLoaded(false)
{
- memset(&iLibQt5Qml, 0, sizeof(iLibQt5Qml));
- // Load the actual import library
- QQmlComponent* component = new QQmlComponent(iEngine);
- component->setData(QString("import QtQuick 2.0\nimport %1 %2.%3\nQtObject {}").
- arg(iModule).arg(iMajor).arg(iMinor).toUtf8(), QUrl());
- if (component->status() == QQmlComponent::Ready) {
- delete component->create();
- // Resolve unstable symbols
- iHandle = dlopen(LIBQT5QML_SO, RTLD_LAZY);
- if (iHandle) {
- for (uint i = 0; i < NUM_FUNCTIONS; i++) {
- iLibQt5Qml.ptr[i] = dlsym(iHandle, QmlTypeSymbols[i]);
- HDEBUG(QmlTypeSymbols[i] << (iLibQt5Qml.ptr[i] ? "OK" : "missing"));
- }
+ HASSERT(gLibQt5Qml.iHandle);
+ if (gLibQt5Qml.iHandle) {
+ // Load the actual import library
+ QQmlComponent* component = new QQmlComponent(iEngine);
+ component->setData(QString("import QtQuick 2.0\nimport %1 %2.%3\nQtObject {}").
+ arg(iModule).arg(iMajor).arg(iMinor).toUtf8(), QUrl());
+ if (component->status() == QQmlComponent::Ready) {
+ delete component->create();
+ iLoaded = true;
} else {
- HWARN("Failed to load" << LIBQT5QML_SO);
+ HWARN(component->errors());
}
- iLoaded = true;
- } else {
- HWARN(component->errors());
- }
- delete component;
-}
-
-HarbourPluginLoader::Private::~Private()
-{
- if (iHandle) {
- dlclose(iHandle);
+ delete component;
}
}
@@ -244,16 +262,16 @@
if (aType && iEngine) {
// Get around the ABI break in Qt 5.6
QQmlAttachedPropertiesFunc attachedPropertiesFunction =
- iLibQt5Qml.fn.AttachedPropertiesFunctionProc ?
- iLibQt5Qml.fn.AttachedPropertiesFunctionProc(aType) :
- iLibQt5Qml.fn.AttachedPropertiesFunctionProc6 ?
- iLibQt5Qml.fn.AttachedPropertiesFunctionProc6(aType, iEngine->d_func()) :
+ gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc ?
+ gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc(aType) :
+ gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc6 ?
+ gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc6(aType, iEngine->d_func()) :
NULL;
const QMetaObject *attachedPropertiesMetaObject =
- iLibQt5Qml.fn.AttachedPropertiesTypeProc ?
- iLibQt5Qml.fn.AttachedPropertiesTypeProc(aType) :
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourPolicyPlugin.cpp
^
|
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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 "HarbourPolicyPlugin.h"
+#include "HarbourDebug.h"
+
+// Workaround for org.nemomobile.policy (or Nemo.Policy) not being
+// allowed in harbour apps
+
+HarbourPolicyPlugin* HarbourPolicyPlugin::gInstance = Q_NULLPTR;
+
+const char HarbourPolicyPlugin::RESOURCE_QML_TYPE[] = "Resource";
+const char HarbourPolicyPlugin::PERMISSIONS_QML_TYPE[] = "Permissions";
+
+HarbourPolicyPlugin::HarbourPolicyPlugin(
+ QQmlEngine* aEngine) :
+ HarbourPluginLoader(aEngine, "org.nemomobile.policy", 1, 0)
+{
+}
+
+HarbourPolicyPlugin::~HarbourPolicyPlugin()
+{
+ HASSERT(gInstance == this);
+ gInstance = Q_NULLPTR;
+}
+
+void
+HarbourPolicyPlugin::registerTypes(
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ reRegisterType(RESOURCE_QML_TYPE, aModule, aMajor, aMinor);
+ reRegisterType(PERMISSIONS_QML_TYPE, aModule, aMajor, aMinor);
+}
+
+void
+HarbourPolicyPlugin::registerTypes(
+ QQmlEngine* aEngine,
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ if (!gInstance) {
+ gInstance = new HarbourPolicyPlugin(aEngine);
+ }
+ gInstance->registerTypes(aModule, aMajor, aMinor);
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourProcessState.cpp
^
|
@@ -0,0 +1,75 @@
+/*
+ * 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>
+
+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;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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);
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourSystem.cpp
^
|
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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 "HarbourSystem.h"
+#include "HarbourDebug.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#ifdef LIBDIR
+# define HARBOUR_LIBDIR LIBDIR
+#elif defined __aarch64__
+# define HARBOUR_LIBDIR "/usr/lib64"
+#else
+# define HARBOUR_LIBDIR "/usr/lib"
+#endif
+
+void* HarbourDlopen(const char* aLibFile, int aFlags)
+{
+ const char* libdir = HARBOUR_LIBDIR;
+ const size_t libdir_len = strlen(libdir);
+ const size_t libfile_len = strlen(aLibFile);
+ char* filename = (char*) malloc(libdir_len + libfile_len + 2);
+ void* handle;
+
+ memcpy(filename, libdir, libdir_len);
+ memcpy(filename + libdir_len + 1, aLibFile, libfile_len);
+ filename[libdir_len] = '/';
+ filename[libdir_len + 1 + libfile_len] = '\0';
+ handle = dlopen(filename, aFlags);
+ if (!handle) {
+ HWARN("Failed to load" << filename);
+ }
+ free(filename);
+ return handle;
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -0,0 +1,282 @@
+/*
+ * 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:
+ *
+ * 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 "HarbourSystemInfo.h"
+#include "HarbourDebug.h"
+
+#include <QHash>
+#include <QVector>
+#include <QStringList>
+#include <QFile>
+#include <QTextStream>
+
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+// ==========================================================================
+// HarbourSystemInfo::Private
+// ==========================================================================
+
+class HarbourSystemInfo::Private
+{
+public:
+ static const QString NAME;
+ static const QString VERSION_ID;
+
+public:
+ Private();
+
+ static QHash<QString,QString> parseFile(QString aFileName, const QStringList aKeys);
+ static QHash<QString,QString> parseOsRelease(const QStringList aKeys);
+ static QVector<uint> parseVersion(QString aVersion);
+ 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");
+const QString HarbourSystemInfo::Private::VERSION_ID("VERSION_ID");
+
+HarbourSystemInfo::Private::Private()
+{
+ QStringList keys;
+ keys.append(NAME);
+ keys.append(VERSION_ID);
+
+ QHash<QString,QString> values(parseOsRelease(keys));
+ iName = values.value(NAME);
+ iVersion = values.value(VERSION_ID);
+ iParsedVersion = parseVersion(iVersion);
+}
+
+inline QHash<QString,QString> HarbourSystemInfo::Private::parseOsRelease(const QStringList aKeys)
+{
+ return parseFile("/etc/os-release", aKeys);
+}
+
+QHash<QString,QString> HarbourSystemInfo::Private::parseFile(QString aPath, const QStringList aKeys)
+{
+ QFile file(aPath);
+ QHash<QString,QString> result;
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ HDEBUG("Parsing" << qPrintable(aPath));
+ QTextStream in(&file);
+ while (!in.atEnd() && result.size() < aKeys.size()) {
+ const QString line = in.readLine();
+ const int sep = line.indexOf('=');
+ if (sep > 0 && (sep + 1) < line.length()) {
+ const QString key(line.left(sep));
+ if (aKeys.contains(key)) {
+ QString value(line.mid(sep + 1));
+ const int len = value.length();
+ if (len > 1 && value.at(0) == '"' && value.at(len - 1) == '"') {
+ value = value.mid(1, len - 2);
+ }
+ value = value.replace("\\\"", "\"");
+ HDEBUG(qPrintable(key) << "=" << qPrintable(value));
+ result.insert(key, value);
+ }
+ }
+ }
+ }
+ return result;
+}
+
+QVector<uint> HarbourSystemInfo::Private::parseVersion(QString aVersion)
+{
+ QVector<uint> parsed;
+ QStringList parts(aVersion.split('.', QString::SkipEmptyParts));
+ const int n = qMin(parts.count(),4);
+ for (int i = 0; i < n; i++) {
+ const QString part(parts.at(i));
+ bool ok = false;
+ int val = part.toUInt(&ok);
+ if (ok) {
+ parsed.append(val);
+ } else {
+ break;
+ }
+ }
+ return parsed;
+}
+
+int HarbourSystemInfo::Private::compareVersions(const QVector<uint> aVersion1,
+ const QVector<uint> aVersion2)
+{
+ const int n1 = aVersion1.size();
+ const int n2 = aVersion2.size();
+ const int n = qMin(n1, n2);
+ for (int i = 0; i < n; i++) {
+ const uint v1 = aVersion1.at(i);
+ const uint v2 = aVersion2.at(i);
+ if (v1 > v2) {
+ return 1;
+ } else if (v1 < v2) {
+ return -1;
+ }
+ }
+ return (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
+}
+
+inline int HarbourSystemInfo::Private::compareVersions(const QVector<uint> aVersion1,
+ const QString aVersion2)
+{
+ 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
+// ==========================================================================
+
+HarbourSystemInfo::HarbourSystemInfo(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private)
+{
+ HDEBUG("created");
+}
+
+HarbourSystemInfo::~HarbourSystemInfo()
+{
+ HDEBUG("deleted");
+ delete iPrivate;
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourSystemTime.cpp
^
|
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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 "HarbourSystemTime.h"
+#include "HarbourDebug.h"
+
+#include <QDBusConnection>
+
+#include <gutil_timenotify.h>
+
+// ==========================================================================
+// HarbourSystemTime::Private
+// ==========================================================================
+
+class HarbourSystemTime::Private : public QObject
+{
+ Q_OBJECT
+public:
+ Private(HarbourSystemTime* aSystemTime);
+ ~Private();
+
+ static void timeNotify(GUtilTimeNotify*, void*);
+
+public Q_SLOTS:
+ void onDBusNotify();
+ void notify();
+
+public:
+ GUtilTimeNotify* iNotify;
+ gulong iNotifyId;
+};
+
+HarbourSystemTime::Private::Private(HarbourSystemTime* aParent) :
+ QObject(aParent),
+ iNotify(gutil_time_notify_new()),
+ iNotifyId(gutil_time_notify_add_handler(iNotify, timeNotify, this))
+{
+ QDBusConnection::systemBus().connect("com.nokia.time", "/com/nokia/time",
+ "com.nokia.time", "settings_changed", this, SLOT(onDBusNotify()));
+}
+
+HarbourSystemTime::Private::~Private()
+{
+ gutil_time_notify_remove_handler(iNotify, iNotifyId);
+ gutil_time_notify_unref(iNotify);
+}
+
+void HarbourSystemTime::Private::timeNotify(GUtilTimeNotify*, void* aSelf)
+{
+ HDEBUG("System time changed");
+ QMetaObject::invokeMethod((QObject*)aSelf, "notify");
+}
+
+void HarbourSystemTime::Private::onDBusNotify()
+{
+ HDEBUG("timed settings changed");
+ notify();
+}
+
+void HarbourSystemTime::Private::notify()
+{
+ HarbourSystemTime* obj = qobject_cast<HarbourSystemTime*>(parent());
+ Q_EMIT obj->preNotify(); // For Date.timeZoneUpdated()
+ Q_EMIT obj->notify(); // For everything else
+}
+
+// ==========================================================================
+// HarbourSystemTime
+// ==========================================================================
+
+HarbourSystemTime::HarbourSystemTime(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+ HDEBUG("created");
+}
+
+HarbourSystemTime::~HarbourSystemTime()
+{
+ HDEBUG("deleted");
+ delete iPrivate;
+}
+
+// Callback for qmlRegisterSingletonType<HarbourSystemTime>
+QObject* HarbourSystemTime::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourSystemTime();
+}
+
+// Getter for notification property which can be used to force
+// re-evaluation of a JavaScript expression. Always returns an
+// empty string.
+QString HarbourSystemTime::emptyString()
+{
+ return QString();
+}
+
+QSharedPointer<HarbourSystemTime> HarbourSystemTime::sharedInstance()
+{
+ static QWeakPointer<HarbourSystemTime> sSharedInstance;
+ QSharedPointer<HarbourSystemTime> instance = sSharedInstance;
+ if (instance.isNull()) {
+ // QObject::deleteLater protects against trouble in case if the
+ // recipient of the signal drops the last shared reference.
+ sSharedInstance = instance = QSharedPointer<HarbourSystemTime>
+ (new HarbourSystemTime, &QObject::deleteLater);
+ }
+ return instance;
+}
+
+#include "HarbourSystemTime.moc"
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -32,13 +32,14 @@
*/
#include "HarbourTheme.h"
+#include "HarbourSystem.h"
#include "HarbourDebug.h"
#include <QQmlEngine>
#include <dlfcn.h>
-#define SILICA_SO "/usr/lib/libsailfishsilica.so.1"
+#define SILICA_SO "libsailfishsilica.so.1"
#define SILICA_FUNCTIONS(f) \
f("_ZN6Silica5Theme8instanceEv", /* Silica::Theme* Silica::Theme::instance() */ \
QObject*, instance,()) \
@@ -74,8 +75,8 @@
SILICA_FUNCTIONS(SILICA_TYPEDEF)
} SilicaFunctions;
- static const qreal DEFAULT_OPACITY_LOW;
static const qreal DEFAULT_OPACITY_FAINT;
+ static const qreal DEFAULT_OPACITY_LOW;
static const qreal DEFAULT_OPACITY_HIGH;
static const qreal DEFAULT_OPACITY_OVERLAY;
@@ -95,8 +96,8 @@
void* HarbourTheme::Private::gHandle;
HarbourTheme::Private::SilicaFunctions HarbourTheme::Private::gSilica;
-const qreal HarbourTheme::Private::DEFAULT_OPACITY_LOW = 0.2;
-const qreal HarbourTheme::Private::DEFAULT_OPACITY_FAINT = 0.4;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_FAINT = 0.2;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_LOW = 0.4;
const qreal HarbourTheme::Private::DEFAULT_OPACITY_HIGH = 0.6;
const qreal HarbourTheme::Private::DEFAULT_OPACITY_OVERLAY = 0.8;
@@ -137,14 +138,14 @@
{
QObject* silica = instance();
return (silica && gSilica.opacityFaint) ? gSilica.opacityFaint(silica) :
- DEFAULT_OPACITY_LOW;
+ DEFAULT_OPACITY_FAINT;
}
qreal HarbourTheme::Private::opacityLow()
{
QObject* silica = instance();
return (silica && gSilica.opacityLow) ? gSilica.opacityLow(silica) :
- DEFAULT_OPACITY_FAINT;
+ DEFAULT_OPACITY_LOW;
}
qreal HarbourTheme::Private::opacityHigh()
@@ -168,7 +169,7 @@
HarbourTheme::HarbourTheme(QObject* aParent) : QObject(aParent)
{
if (!Private::gHandle) {
- Private::gHandle = dlopen(SILICA_SO, RTLD_LAZY);
+ Private::gHandle = HarbourDlopen(SILICA_SO, RTLD_LAZY);
if (Private::gHandle) {
void** ptr = (void**)&Private::gSilica;
for (uint i = 0; i < NUM_FUNCTIONS; i++) {
@@ -211,8 +212,25 @@
QColor HarbourTheme::invertedPrimaryColor() const
{
- const QRgb rgba = HarbourTheme::primaryColor().rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
+ return invertedColor(Private::primaryColor());
+}
+
+QColor HarbourTheme::invertedColor(const QColor& aColor)
+{
+ if (aColor.isValid()) {
+ const QRgb rgba = aColor.rgba();
+ return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
+ } else {
+ return aColor;
+ }
+}
+
+qreal HarbourTheme::colorDifference(const QColor& aColor1, const QColor& aColor2)
+{
+ const qreal dr = aColor1.red() - aColor2.red();
+ const qreal dg = aColor1.green() - aColor2.green();
+ const qreal db = aColor1.blue() - aColor2.blue();
+ return dr * dr + dg * dg + db * db;
}
HarbourTheme::ColorScheme HarbourTheme::colorScheme() const
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/src/HarbourTransferMethodsModel.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2019 Jolla Ltd.
- * Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2020 Jolla Ltd.
+ * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -22,7 +22,7 @@
* "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
@@ -36,6 +36,7 @@
#include <QTranslator>
#include <QQmlEngine>
+#include <QRegExp>
// ==========================================================================
// HarbourTransferMethodsModel::TransferEngine
@@ -45,82 +46,111 @@
{
Q_OBJECT
- static const char SERVICE[];
- static const char PATH[];
- static const char INTERFACE[];
-
public:
- TransferEngine(QObject* aParent) : QDBusAbstractInterface(SERVICE, PATH,
- INTERFACE, QDBusConnection::sessionBus(), aParent) {}
+ TransferEngine(QObject* aParent) :
+ QDBusAbstractInterface(QStringLiteral("org.nemo.transferengine"),
+ QStringLiteral("/org/nemo/transferengine"), "org.nemo.transferengine",
+ QDBusConnection::sessionBus(), aParent) {}
public: // METHODS
inline QDBusPendingCall transferMethods()
- { return asyncCall("transferMethods"); }
+ { return asyncCall(QStringLiteral("transferMethods")); }
inline QDBusPendingCall transferMethods2()
- { return asyncCall("transferMethods2"); }
+ { return asyncCall(QStringLiteral("transferMethods2")); }
Q_SIGNALS: // SIGNALS
void transferMethodListChanged();
};
-const char HarbourTransferMethodsModel::TransferEngine::SERVICE[] = "org.nemo.transferengine";
-const char HarbourTransferMethodsModel::TransferEngine::PATH[] = "/org/nemo/transferengine";
-const char HarbourTransferMethodsModel::TransferEngine::INTERFACE[] = "org.nemo.transferengine";
-
// ==========================================================================
-// HarbourTransferMethodsModel
+// HarbourTransferMethodsModel::Private
// ==========================================================================
-HarbourTransferMethodsModel::HarbourTransferMethodsModel(QObject* aParent):
- QAbstractListModel(aParent),
+class HarbourTransferMethodsModel::Private: public QObject
+{
+ Q_OBJECT
+ typedef QDBusPendingCallWatcher* (Private::*RequestUpdate)();
+
+public:
+ enum Role {
+ DisplayNameRole = Qt::UserRole + 1,
+ UserNameRole,
+ MethodIdRole,
+ ShareUIPathRole,
+ AccountIdRole,
+ AccountIconRole
+ };
+
+ Private(HarbourTransferMethodsModel* aModel);
+ ~Private();
+
+public:
+ HarbourTransferMethodsModel* parentModel();
+ static QRegExp regExp(QString aRegExp);
+ void filterModel();
+ QDBusPendingCallWatcher* checkTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods2();
+ void setTransferMethods2(HarbourTransferMethodInfo2List aList);
+ bool showAccounts();
+
+private Q_SLOTS:
+ void onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch);
+ void onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch);
+ void onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch);
+ void onShowAccountsFinished(QDBusPendingCallWatcher* aWatch);
+ void requestUpdate();
+
+public:
+ QString iFilter;
+ QList<HarbourTransferMethodInfo2> iMethodList;
+ QList<int> iFilteredList;
+ bool iAccountIconSupported;
+ RequestUpdate iRequestUpdate;
+ QDBusPendingCallWatcher* iUpdateWatcher;
+ QDBusPendingCallWatcher* iShowAccountsWatcher;
+ bool iShowAccountsFailed;
+ TransferEngine* iTransferEngine;
+};
+
+HarbourTransferMethodsModel::Private::Private(HarbourTransferMethodsModel* aModel) :
+ QObject(aModel),
iAccountIconSupported(false),
- iRequestUpdate(&HarbourTransferMethodsModel::checkTransferMethods),
- iUpdateWatcher(Q_NULLPTR)
+ iRequestUpdate(&Private::checkTransferMethods),
+ iUpdateWatcher(Q_NULLPTR),
+ iShowAccountsWatcher(Q_NULLPTR),
+ iShowAccountsFailed(false),
+ iTransferEngine(new TransferEngine(this))
{
- iTransferEngine = new TransferEngine(this);
connect(iTransferEngine,
SIGNAL(transferMethodListChanged()),
SLOT(requestUpdate()));
requestUpdate();
}
-HarbourTransferMethodsModel::~HarbourTransferMethodsModel()
+HarbourTransferMethodsModel::Private::~Private()
{
delete iTransferEngine;
}
-// Callback for qmlRegisterSingletonType<HarbourTransferMethodsModel>
-QObject*
-HarbourTransferMethodsModel::createSingleton(QQmlEngine*, QJSEngine*)
-{
- return new HarbourTransferMethodsModel();
-}
-
-bool HarbourTransferMethodsModel::loadTranslations(QTranslator* aTranslator, QLocale aLocale)
+inline HarbourTransferMethodsModel* HarbourTransferMethodsModel::Private::parentModel()
{
- if (aTranslator->load(aLocale, "sailfish_transferengine_plugins", "-",
- "/usr/share/translations")) {
- return true;
- } else {
- HWARN("Failed to load transferengine plugin translator for" << aLocale);
- return false;
- }
+ return qobject_cast<HarbourTransferMethodsModel*>(parent());
}
-void HarbourTransferMethodsModel::requestUpdate()
+void HarbourTransferMethodsModel::Private::requestUpdate()
{
if (iUpdateWatcher) {
- HDEBUG("dropping pending call");
+ HDEBUG("dropping pending method list query");
iUpdateWatcher->disconnect(this);
delete iUpdateWatcher;
- iUpdateWatcher = Q_NULLPTR;
}
iUpdateWatcher = (this->*iRequestUpdate)();
}
-void HarbourTransferMethodsModel::setTransferMethods2(HarbourTransferMethodInfo2List aList)
+void HarbourTransferMethodsModel::Private::setTransferMethods2(HarbourTransferMethodInfo2List aList)
{
- iRequestUpdate = &HarbourTransferMethodsModel::requestTransferMethods2;
+ iRequestUpdate = &Private::requestTransferMethods2;
HDEBUG(aList.count() << "methods");
if (iMethodList != aList) {
iMethodList = aList;
@@ -128,11 +158,11 @@
}
if (!iAccountIconSupported) {
iAccountIconSupported = true;
- Q_EMIT accountIconSupportedChanged();
+ Q_EMIT parentModel()->accountIconSupportedChanged();
}
}
-QDBusPendingCallWatcher* HarbourTransferMethodsModel::checkTransferMethods()
+QDBusPendingCallWatcher* HarbourTransferMethodsModel::Private::checkTransferMethods()
{
// First try transferMethods2() and see if it works
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher
@@ -142,7 +172,7 @@
return watcher;
}
-QDBusPendingCallWatcher* HarbourTransferMethodsModel::requestTransferMethods()
+QDBusPendingCallWatcher* HarbourTransferMethodsModel::Private::requestTransferMethods()
{
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher
(iTransferEngine->transferMethods(), this);
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/test/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C TestHarbourBase32 $*
+ @$(MAKE) -C TestHarbourBase45 $*
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/harbour-lib/test/coverage/.gitignore
^
|
@@ -0,0 +1,4 @@
+app.gcov
+full.gcov
+report
+*~
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/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
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libaztec/Makefile
^
|
@@ -24,7 +24,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 4
+VERSION_RELEASE = 6
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libaztec/debian/changelog
^
|
@@ -1,3 +1,15 @@
+libaztec (1.0.6) unstable; urgency=low
+
+ * Yet another fix for SP and LF in PUNCT mode
+
+ -- Slava Monich <slava@monich.com> Mon, 06 Jan 2020 05:21:45 +0300
+
+libaztec (1.0.5) unstable; urgency=low
+
+ * Another fix for SP and LF in PUNCT mode
+
+ -- Slava Monich <slava@monich.com> Mon, 06 Jan 2020 01:00:19 +0300
+
libaztec (1.0.4) unstable; urgency=low
* Fixed a bug in encoding of PUNCT blocks
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libaztec/rpm/libaztec.spec
^
|
@@ -1,10 +1,10 @@
Name: libaztec
-Version: 1.0.4
+Version: 1.0.6
Release: 0
Summary: Aztec encoder
Group: Development/Libraries
License: BSD
-URL: https://github.com/monich/aztec
+URL: https://github.com/monich/libaztec
Source: %{name}-%{version}.tar.bz2
BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(glib-2.0)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libaztec/src/aztec_encode.c
^
|
@@ -591,7 +591,17 @@
/* Caller made sure that len > 0 */
last_block->data = ptr;
last_block->len = 1;
- last_block->mode = mode[*ptr++];
+ last_block->mode = mode[*ptr];
+
+ /*
+ * PUNCT mode can't start with LF or SP, those can only be the
+ * second character in a sequence.
+ */
+ if (*ptr == LF || *ptr == SP) {
+ last_block->mode &= ~MODE_PUNCT;
+ }
+
+ ptr++;
/* Split data into blocks */
while (ptr < end) {
@@ -642,6 +652,14 @@
continue;
}
+ /*
+ * PUNCT mode can't start with LF or SP, those can only be the
+ * second character in a sequence.
+ */
+ if (c == LF || c == SP) {
+ m &= ~MODE_PUNCT;
+ }
+
/* Start next block */
block = g_slice_new0(AztecBlock);
block->data = ptr - 1;
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libaztec/unit/unit_encode/unit_encode.c
^
|
@@ -509,6 +509,105 @@
aztec_symbol_free(symbol);
}
+/* Punct5 */
+
+static
+void
+test_punct5(
+ void)
+{
+ static const char msg[] = "a\n=";
+ static const guint8 data[15][2] = {
+ { 0x94, 0x4c }, /* # # # ## # */
+ { 0x93, 0x50 }, /* ## # # # # */
+ { 0x0d, 0x32 }, /* # ## # ## */
+ { 0xfc, 0x5f }, /* ########### # */
+ { 0x08, 0x68 }, /* # # ## */
+ { 0xe9, 0x1b }, /* # # ##### ## */
+ { 0x2f, 0x2a }, /* #### # # # # */
+ { 0xa9, 0x3a }, /* # # # # # ### */
+ { 0x29, 0x4a }, /* # # # # # # */
+ { 0xe9, 0x6b }, /* # # ##### # ## */
+ { 0x0b, 0x28 }, /* ## # # # */
+ { 0xf8, 0x3f }, /* ########### */
+ { 0x70, 0x67 }, /* ### ### ## */
+ { 0x51, 0x6f }, /* # # # #### ## */
+ { 0x92, 0x3b } /* # # ### ### */
+ };
+ AztecSymbol* symbol = aztec_encode(msg, sizeof(msg) - 1, 0);
+
+ g_assert(symbol);
+ g_assert(symbol->size == G_N_ELEMENTS(data));
+ test_check2(symbol, data);
+ aztec_symbol_free(symbol);
+}
+
+/* Punct6 */
+
+static
+void
+test_punct6(
+ void)
+{
+ static const char msg[] = " =";
+ static const guint8 data[15][2] = {
+ { 0x7c, 0x29 }, /* ##### # # # */
+ { 0x07, 0x18 }, /* ### ## */
+ { 0x0d, 0x54 }, /* # ## # # # */
+ { 0xfd, 0x5f }, /* # ########### # */
+ { 0x0c, 0x58 }, /* ## ## # */
+ { 0xee, 0x1b }, /* ### ##### ## */
+ { 0x28, 0x1a }, /* # # # ## */
+ { 0xa8, 0x1a }, /* # # # # ## */
+ { 0x2a, 0x4a }, /* # # # # # # */
+ { 0xed, 0x3b }, /* # ## ##### ### */
+ { 0x0c, 0x78 }, /* ## #### */
+ { 0xfb, 0x7f }, /* ## ############ */
+ { 0x43, 0x21 }, /* ## # # # */
+ { 0xab, 0x4b }, /* ## # # ### # # */
+ { 0xd9, 0x28 } /* # ## ## # # */
+ };
+ AztecSymbol* symbol = aztec_encode(msg, sizeof(msg) - 1, 0);
+
+ g_assert(symbol);
+ g_assert(symbol->size == G_N_ELEMENTS(data));
+ test_check2(symbol, data);
+ aztec_symbol_free(symbol);
+}
+
+/* Punct7 */
+
+static
+void
+test_punct7(
+ void)
+{
+ static const char msg[] = "\n+";
+ static const guint8 data[15][2] = {
+ { 0x38, 0x2a }, /* ### # # # */
+ { 0xff, 0x14 }, /* ######## # # */
+ { 0x0d, 0x54 }, /* # ## # # # */
+ { 0xfd, 0x1f }, /* # ########### */
+ { 0x0d, 0x38 }, /* # ## ### */
+ { 0xef, 0x3b }, /* #### ##### ### */
+ { 0x28, 0x3a }, /* # # # ### */
+ { 0xa8, 0x1a }, /* # # # # ## */
+ { 0x2a, 0x4a }, /* # # # # # # */
+ { 0xec, 0x1b }, /* ## ##### ## */
+ { 0x0c, 0x18 }, /* ## ## */
+ { 0xfb, 0x3f }, /* ## ########### */
+ { 0x43, 0x41 }, /* ## # # # */
+ { 0x9a, 0x19 }, /* # ## ## ## */
+ { 0xe8, 0x0b } /* # ##### # */
+ };
+ AztecSymbol* symbol = aztec_encode(msg, sizeof(msg) - 1, 0);
+
+ g_assert(symbol);
+ g_assert(symbol->size == G_N_ELEMENTS(data));
+ test_check2(symbol, data);
+ aztec_symbol_free(symbol);
+}
+
/* Digit */
static
@@ -753,6 +852,9 @@
g_test_add_func(TEST_("punct2"), test_punct2);
g_test_add_func(TEST_("punct3"), test_punct3);
g_test_add_func(TEST_("punct4"), test_punct4);
+ g_test_add_func(TEST_("punct5"), test_punct5);
+ g_test_add_func(TEST_("punct6"), test_punct6);
+ g_test_add_func(TEST_("punct7"), test_punct7);
g_test_add_func(TEST_("digit"), test_digit);
g_test_add_func(TEST_("compact4"), test_compact4);
g_test_add_func(TEST_("full4"), test_full4);
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/.github/workflows/cmake-windows.yml
^
|
@@ -0,0 +1,53 @@
+name: CMake
+
+on: [push, pull_request]
+
+env:
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
+ BUILD_TYPE: Release
+
+jobs:
+ build:
+ # The CMake configure and build commands are platform agnostic and should work equally
+ # well on Windows or Mac. You can convert this to a matrix build if you need
+ # cross-platform coverage.
+ # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: run vcpkg
+ uses: lukka/run-vcpkg@v3
+ with:
+ vcpkgArguments: getopt:x64-windows libiconv:x64-windows libpng:x64-windows
+ vcpkgDirectory: '${{ github.workspace }}/vcpkg'
+ vcpkgGitCommitId: 'fca18ba3572f8aebe3b8158c359db62a7e26134e'
+
+ - name: Create Build Environment
+ # Some projects don't allow in-source building, so create a separate build directory
+ # We'll use this as our working directory for all subsequent commands
+ run: cmake -E make_directory ${{runner.workspace}}/build
+
+ - name: Configure CMake
+ # Use a bash shell so we can use the same syntax for environment variable
+ # access regardless of the host operating system
+ shell: bash
+ working-directory: ${{runner.workspace}}/build
+ # Note the current convention is to use the -S and -B options here to specify source
+ # and build directories, but this is only available with CMake 3.13 and higher.
+ # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
+ run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DWITH_TESTS=yes
+
+ - name: Build
+ working-directory: ${{runner.workspace}}/build
+ shell: bash
+ # Execute the build. You can specify a specific target with "--target <NAME>"
+ run: cmake --build . --config $BUILD_TYPE
+
+ - name: Test
+ working-directory: ${{runner.workspace}}/build
+ shell: bash
+ # Execute tests defined by the CMake configuration.
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
+ run: ctest -C $BUILD_TYPE
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/.github/workflows/cmake.yml
^
|
@@ -0,0 +1,46 @@
+name: CMake
+
+on: [push]
+
+env:
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
+ BUILD_TYPE: Release
+
+jobs:
+ build:
+ # The CMake configure and build commands are platform agnostic and should work equally
+ # well on Windows or Mac. You can convert this to a matrix build if you need
+ # cross-platform coverage.
+ # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Create Build Environment
+ # Some projects don't allow in-source building, so create a separate build directory
+ # We'll use this as our working directory for all subsequent commands
+ run: cmake -E make_directory ${{runner.workspace}}/build
+
+ - name: Configure CMake
+ # Use a bash shell so we can use the same syntax for environment variable
+ # access regardless of the host operating system
+ shell: bash
+ working-directory: ${{runner.workspace}}/build
+ # Note the current convention is to use the -S and -B options here to specify source
+ # and build directories, but this is only available with CMake 3.13 and higher.
+ # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
+ run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTS=yes -DBUILD_SHARED_LIBS=on
+
+ - name: Build
+ working-directory: ${{runner.workspace}}/build
+ shell: bash
+ # Execute the build. You can specify a specific target with "--target <NAME>"
+ run: cmake --build . --config $BUILD_TYPE
+
+ - name: Test
+ working-directory: ${{runner.workspace}}/build
+ shell: bash
+ # Execute tests defined by the CMake configuration.
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
+ run: ctest -C $BUILD_TYPE
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/.github/workflows/configure.yml
^
|
@@ -0,0 +1,21 @@
+name: configure CI
+
+on: [push, pull_request]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: generate configure script
+ run: ./autogen.sh
+ - name: configure
+ run: ./configure --with-tests
+ - name: make
+ run: make
+ - name: make check
+ run: make check
+ - name: make distcheck
+ run: make distcheck
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/.gitignore
^
|
@@ -52,6 +52,7 @@
use/install-sh
use/ltmain.sh
use/missing
+use/test-driver
html/
massif.out.*
gmon.out
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/CMakeLists.txt
^
|
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1.0)
-project(QRencode VERSION 4.1.0 LANGUAGES C)
+project(QRencode VERSION 4.1.1 LANGUAGES C)
option(WITH_TOOLS "Build utility tools" YES )
option(WITH_TESTS "Build tests" NO )
@@ -41,6 +41,8 @@
check_include_file(string.h HAVE_STRING_H )
check_include_file(getopt.h HAVE_GETOPT_H )
check_include_file(sys/time.h HAVE_SYS_TIME_H)
+check_include_file(time.h HAVE_TIME_H )
+check_include_file(pthread.h HAVE_PTHREAD_H )
check_function_exists(strdup HAVE_STRDUP)
@@ -80,7 +82,7 @@
if(WITH_TOOLS)
find_path(GETOPT_INCLUDE_DIR getopt.h PATH_SUFFIXES include)
- find_library(GETOPT_LIBRARIES wingetopt PATH_SUFFIXES lib)
+ find_library(GETOPT_LIBRARIES getopt PATH_SUFFIXES lib)
include_directories(${GETOPT_INCLUDE_DIR})
endif(WITH_TOOLS)
endif(MSVC)
@@ -141,7 +143,11 @@
add_executable(qrenc qrenc.c)
set_target_properties(qrenc PROPERTIES OUTPUT_NAME qrencode)
- target_link_libraries(qrenc qrencode PNG::PNG)
+ if(NOT WITHOUT_PNG)
+ target_link_libraries(qrenc qrencode PNG::PNG)
+ else()
+ target_link_libraries(qrenc qrencode)
+ endif()
if(MSVC)
target_link_libraries(qrenc ${GETOPT_LIBRARIES})
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/ChangeLog
^
|
@@ -1,7 +1,83 @@
+2020.09.28 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [hotfix]
+ * qrinput.c, tests/test_estimatebit.c:
+ - Fixed a bug in the estimation of the Micro QR Code's data length
+ in QRinput_estimateBitStreamSizeOfEntry() has been fixed.
+ - Fixed a bug in the calculation of the Micro QR Code's data capacity in
+ QRinput_encodeBitStream().
+ - A test case to test the bugs above has been added.
+ - Level check failure in QRinput_new2() on Windows has been fixed.
+ * Bumped version to 4.1.1.
+
+2020.08.29 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [release-4.1.0]
+ * .github/workflows/{cmake,configure,cmake-windows}.yml:
+ - Github actions CI scripts have been added.
+ * tests/test_bitstream.c:
+ - Fixed memory leak.
+ * configure.ac, tests/{prof,pthread}_qrencode.c:
+ - Make configure to define HAVE_SYS_TIME_H in config.h.
+ * CMakeLists.txt:
+ - 'wingetopt' has been replaced to 'getopt'.
+ * qrencode.c, tests/test_qrencode.c:
+ - ECLEVEL check has been improved.
+ * .gitignore:
+ - Added 'use/test-driver'.
+
+2020.08.28 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [develop]
+ * Made a develoment branch.
+ * test_qrspec.c:
+ - Typo fixes.
+ * qrinput.[ch], tests/{test_qrencode.c, test_qrinput.c}:
+ - A precise boundary check has been introduced to
+ QRinput_estimateVersion(). (closes #160)
+ * qrinput.c, qrencode.c, tests/test_qrencode.c, qrenc.c, qrencode.1.in:
+ - QRinput_encodeMode*() now throws ERANGE when encoding Micro QR Code
+ and an appropriate version number was not specified.
+ - Now Micro QR Code also allows auto version adjustment.
+ * qrenc.c, qrencode.1.in:
+ - The synopsis has been improved. (Thanks to @jidanni) (closes #155)
+ - A new option '--strict-version' has been introduced.
+ * split.c:
+ - A tail recursion has been eliminated. (Thanks to @4061N) (closes #144)
+ * tests/*:
+ - All test programs are now TAP-ready. Now you can run all test programs
+ by 'make check'.(Thanks to @jtojnar) (closes #117)
+ * qrinput.c:
+ - Return value was ignored. (Thanks to @xiaoyur347) (closed #143)
+ * README.md, NEWS:
+ - Various documentation improvements and updates.
+ [release-4.1.0]
+ * Bumped version to 4.1.0.
+ * qrencode.h:
+ - Document improvements.
+ * qrenc.c, qrencode.1.in:
+ - Added 'UTF8i' and 'ANSIUTF8i' to the descriptions of the corresponding
+ options. (Thanks to @Khoyo) (merged #138)
+
+2020.02.23 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [master]
+ * CMakeLists.txt, README.md:
+ - Merged #158 (Thanks to @neheb):
+ - Fixed the compile-time issue of the environment without libpng.
+
+2020.02.23 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [master]
+ * README.md:
+ - Merged #151 (Thanks to @NancyLi1013):
+ - Added vcpkg installation instructions.
+
+2018.11.09 Kentaro Fukuchi <kentaro@fukuchi.org>
+ [master]
+ * configure.ac, README.md:
+ - Merged #137 (Thanks to @abelbeck and @charmander):
+ - 'too many arguments' bug has been fixed.
+
2018.07.28 Kentaro Fukuchi <kentaro@fukuchi.org>
[master]
* CMakeLists.txt:
- - Merged #133 (Thanks to @sdf5)
+ - Merged #133 (Thanks to @sdf5):
- Change CMAKE_SORUCE_DIR to CMAKE_CURRENT_SORUCE_DIR in
CMAKE_MODULE_PATH
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/NEWS
^
|
@@ -1,20 +1,31 @@
libqrencode NEWS - Overview of changes
======================================
-Version 4.1.0 (2018.6.x)
-------------------------
+Version 4.1.1 (2020.9.28)
+-------------------------
+* Some minor bugs in Micro QR Code generation have been fixed.
+ * The data capacity calculations are now correct. These bugs probably did not
+ affect the Micro QR Code generation.
+
+Version 4.1.0 (2020.8.29)
+-------------------------
* Command line tool "qrencode" has been improved:
- * New option "--inline" has been added. (Thanks to @jp-bennett)
- * UTF8 mode now supports ANSI256 color. (Thanks to András Veres-
+ * New option "--inline" has been added. (Thanks to @jp-bennett)
+ * New option "--strict-version" has been added.
+ * UTF8 mode now supports ANSI256 color. (Thanks to András Veres-
Szentkirályi)
+* Micro QR Code no longer requires to specify the version number.
+* 'make check' allows to run the test programs. (Thanks to Jan Tojnar)
* Some compile time warnings have been fixed.
* Various CMake support improvements. (Thanks to @mgorny and @sdf5)
-* Some minor bug fixes. (Thank to Lonnie Abelbeck)
+* Some minor bug fixes. (Thanks to Lonnie Abelbeck and Frédéric Wang)
+* Some documentation/manpage improvements. (Thanks to Dan Jacobson)
+* Some performance improvements. (Thanks to @4061N and Mika Lindqvist)
Release Note:
-The internal representation of the output code has been changed slightly -
+The internal representation of the output code has been slightly changed -
the second bit from LSB side now represents; 1:ECC bit / 0:data bit.
-This is only for debug purpose and does not affect user applications.
+This change is only for debug purposes and does not affect user applications.
Version 4.0.2 (2018.6.6)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/README.md
^
|
@@ -1,6 +1,6 @@
# libqrencode - a fast and compact QR Code encoding library [![Build Status](https://travis-ci.org/fukuchi/libqrencode.png?branch=master)](https://travis-ci.org/fukuchi/libqrencode)
-**Attention:** This repository contains the development version of libqrencode. See <https://fukuchi.org/works/qrencode/> for the official stable releases. At this moment, the latest stable release is version 4.0.2.
+**Attention:** This repository contains the development version of libqrencode. See <https://fukuchi.org/works/qrencode/> for the official stable releases. At this moment, the latest stable release is version 4.1.1.
GENERAL INFORMATION
===================
@@ -87,6 +87,24 @@
When you want to build the test programs, give "--with-tests" option to
configure, or "-DWITH\_TESTS=YES" to cmake.
+### Building libqrencode with vcpkg
+
+You can download and install libqrencode using the
+[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
+
+```
+git clone https://github.com/Microsoft/vcpkg.git
+cd vcpkg
+./bootstrap-vcpkg.sh
+./vcpkg integrate install
+./vcpkg install libqrencode
+```
+
+The libqrencode port in vcpkg is kept up to date by Microsoft team members and
+community contributors. If the version is out of date, please
+[create an issue or pull request](https://github.com/Microsoft/vcpkg) on the
+vcpkg repository.
+
USAGE
=====
@@ -192,17 +210,22 @@
- improved CMake support
* @vanillahsu - bug fix patch
* @Ation - bug fix patch
-* Jonathan Bennett - Addedd "--inline" option to qrencode
+* Jonathan Bennett - Added "--inline" option to qrencode
* András Veres-Szentkirályi
- ANSI256UTF8 support
* @sdf5 - improved CMake support
* Lonnie Abelbeck (@abelbeck)
- bug fix patch
+* @4061N - performance improvement patch
+* Rosen Penev (@neheb) - CMake bug fix patch
+* Mika Lindqvist (@mtl1979)
+ - replacement for gettimeofday() for Windows.
* Shigeyuki Hirai, Paul Janssens, wangsai, Gavan Fantom, Matthew Baker,
Rob Ryan, Fred Steinhaeuser, Terry Burton, @chisj, @vlad417, Petr,
Hassan Hajji, Emmanuel Blot, ßlúèÇhîp, Heiko Becker, Gavin Andresen,
David Binderman, @ralgozino, Sean McMurray, Vlad Bespalov (@win32asm),
Antenore Gatta, Yoshimichi Inoue, Sunil Maganally, Norman Gray,
Danomi Manchego, @minus7, Ian Sweet, @qianchenglenger, Ronald Michaels,
- Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules
+ Yuji Ueno, Jakub Wilk, @KangLin, @c-273, @thebunnyrules, @NancyLi1013,
+ Frédéric Wang, Dan Jacobson, Jan Tojnar, @xiaoyur347, @charmander
- bug report / suggestion / typo fixes
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/configure.ac
^
|
@@ -1,6 +1,6 @@
m4_define([__MAJOR_VERSION], [4])dnl
m4_define([__MINOR_VERSION], [1])dnl
-m4_define([__MICRO_VERSION], [0])dnl
+m4_define([__MICRO_VERSION], [1])dnl
m4_define([__VERSION], [__MAJOR_VERSION.__MINOR_VERSION.__MICRO_VERSION])dnl
AC_INIT(QRencode, __VERSION)
@@ -27,6 +27,7 @@
AC_C_CONST
AC_C_INLINE
AC_HEADER_STDC
+AC_CHECK_HEADERS(sys/time.h)
LT_INIT
AC_PROG_CC
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrenc.c
^
|
@@ -46,6 +46,7 @@
static int svg_path = 0;
static int micro = 0;
static int inline_svg = 0;
+static int strict_versioning = 0;
static QRecLevel level = QR_ECLEVEL_L;
static QRencodeMode hint = QR_MODE_8;
static unsigned char fg_color[4] = {0, 0, 0, 255};
@@ -73,28 +74,29 @@
static enum imageType image_type = PNG_TYPE;
static const struct option options[] = {
- {"help" , no_argument , NULL, 'h'},
- {"output" , required_argument, NULL, 'o'},
- {"read-from" , required_argument, NULL, 'r'},
- {"level" , required_argument, NULL, 'l'},
- {"size" , required_argument, NULL, 's'},
- {"symversion" , required_argument, NULL, 'v'},
- {"margin" , required_argument, NULL, 'm'},
- {"dpi" , required_argument, NULL, 'd'},
- {"type" , required_argument, NULL, 't'},
- {"structured" , no_argument , NULL, 'S'},
- {"kanji" , no_argument , NULL, 'k'},
- {"casesensitive", no_argument , NULL, 'c'},
- {"ignorecase" , no_argument , NULL, 'i'},
- {"8bit" , no_argument , NULL, '8'},
- {"rle" , no_argument , &rle, 1},
- {"svg-path" , no_argument , &svg_path, 1},
- {"inline" , no_argument , &inline_svg, 1},
- {"micro" , no_argument , NULL, 'M'},
- {"foreground" , required_argument, NULL, 'f'},
- {"background" , required_argument, NULL, 'b'},
- {"version" , no_argument , NULL, 'V'},
- {"verbose" , no_argument , &verbose, 1},
+ {"help" , no_argument , NULL, 'h'},
+ {"output" , required_argument, NULL, 'o'},
+ {"read-from" , required_argument, NULL, 'r'},
+ {"level" , required_argument, NULL, 'l'},
+ {"size" , required_argument, NULL, 's'},
+ {"symversion" , required_argument, NULL, 'v'},
+ {"margin" , required_argument, NULL, 'm'},
+ {"dpi" , required_argument, NULL, 'd'},
+ {"type" , required_argument, NULL, 't'},
+ {"structured" , no_argument , NULL, 'S'},
+ {"kanji" , no_argument , NULL, 'k'},
+ {"casesensitive" , no_argument , NULL, 'c'},
+ {"ignorecase" , no_argument , NULL, 'i'},
+ {"8bit" , no_argument , NULL, '8'},
+ {"micro" , no_argument , NULL, 'M'},
+ {"rle" , no_argument , &rle, 1},
+ {"svg-path" , no_argument , &svg_path, 1},
+ {"inline" , no_argument , &inline_svg, 1},
+ {"strict-version", no_argument , &strict_versioning, 1},
+ {"foreground" , required_argument, NULL, 'f'},
+ {"background" , required_argument, NULL, 'b'},
+ {"version" , no_argument , NULL, 'V'},
+ {"verbose" , no_argument , &verbose, 1},
{NULL, 0, NULL, 0}
};
@@ -109,7 +111,7 @@
if(help) {
if(longopt) {
fprintf(out,
-"Usage: qrencode [OPTION]... [STRING]\n"
+"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n"
"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
" -h, --help display the help message. -h displays only the help of short\n"
" options.\n\n"
@@ -132,27 +134,31 @@
" specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
" -d NUMBER, --dpi=NUMBER\n"
" specify the DPI of the generated PNG. (default=72)\n\n"
-" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8},\n"
-" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n"
+" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8},\n"
+" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n"
" specify the type of the generated image. (default=PNG)\n\n"
" -S, --structured\n"
-" make structured symbols. Version must be specified.\n\n"
+" make structured symbols. Version must be specified with '-v'.\n\n"
" -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
" -c, --casesensitive\n"
" encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
" -i, --ignorecase\n"
" ignore case distinctions and use only upper-case characters.\n\n"
" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
+" -M, --micro encode in a Micro QR Code.\n\n"
" --rle enable run-length encoding for SVG.\n\n"
" --svg-path\n"
" use single path to draw modules for SVG.\n\n"
-" --inline only useful for SVG output, generates an SVG without the XML tag.\n"
-" -M, --micro encode in a Micro QR Code. (experimental)\n\n"
+" --inline only useful for SVG output, generates an SVG without the XML tag.\n\n"
" --foreground=RRGGBB[AA]\n"
" --background=RRGGBB[AA]\n"
" specify foreground/background color in hexadecimal notation.\n"
" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
" Color output support available only in PNG, EPS and SVG.\n\n"
+" --strict-version\n"
+" disable automatic version number adjustment. If the input data is\n"
+" too large for the specified version, the program exits with the\n"
+" code of 1.\n\n"
" -V, --version\n"
" display the version number and copyrights of the qrencode.\n\n"
" --verbose\n"
@@ -171,7 +177,7 @@
);
} else {
fprintf(out,
-"Usage: qrencode [OPTION]... [STRING]\n"
+"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n"
"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
" -h display this message.\n"
" --help display the usage of long options.\n"
@@ -186,9 +192,9 @@
" -v NUMBER specify the minimum version of the symbol. (default=auto)\n"
" -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n"
" -d NUMBER specify the DPI of the generated PNG. (default=72)\n"
-" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}\n"
+" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n"
" specify the type of the generated image. (default=PNG)\n"
-" -S make structured symbols. Version must be specified.\n"
+" -S make structured symbols. Version number must be specified with '-v'.\n"
" -k assume that the input text contains kanji (shift-jis).\n"
" -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
" -i ignore case distinctions and use only upper-case characters.\n"
@@ -1034,6 +1040,10 @@
}
exit(EXIT_FAILURE);
}
+ if(strict_versioning && version > 0 && qrcode->version != version) {
+ fprintf(stderr, "Failed to encode the input data: Input data too large\n");
+ exit(EXIT_FAILURE);
+ }
if(verbose) {
fprintf(stderr, "File: %s, Version: %d\n", (outfile!=NULL)?outfile:"(stdout)", qrcode->version);
@@ -1399,7 +1409,7 @@
if(intext == NULL) {
fp = infile == NULL ? stdin : fopen(infile,"r");
if(fp == 0) {
- fprintf(stderr, "Can not read input file %s.\n", infile);
+ fprintf(stderr, "Cannot read input file %s.\n", infile);
exit(EXIT_FAILURE);
}
intext = readFile(fp,&length);
@@ -1407,10 +1417,10 @@
}
if(micro && version > MQRSPEC_VERSION_MAX) {
- fprintf(stderr, "Version should be less or equal to %d.\n", MQRSPEC_VERSION_MAX);
+ fprintf(stderr, "Version number should be less or equal to %d.\n", MQRSPEC_VERSION_MAX);
exit(EXIT_FAILURE);
} else if(!micro && version > QRSPEC_VERSION_MAX) {
- fprintf(stderr, "Version should be less or equal to %d.\n", QRSPEC_VERSION_MAX);
+ fprintf(stderr, "Version number should be less or equal to %d.\n", QRSPEC_VERSION_MAX);
exit(EXIT_FAILURE);
}
@@ -1423,10 +1433,6 @@
}
if(micro) {
- if(version == 0) {
- fprintf(stderr, "Version must be specified to encode a Micro QR Code symbol.\n");
- exit(EXIT_FAILURE);
- }
if(structured) {
fprintf(stderr, "Micro QR Code does not support structured symbols.\n");
exit(EXIT_FAILURE);
@@ -1435,7 +1441,7 @@
if(structured) {
if(version == 0) {
- fprintf(stderr, "Version must be specified to encode structured symbols.\n");
+ fprintf(stderr, "Version number must be specified to encode structured symbols.\n");
exit(EXIT_FAILURE);
}
qrencodeStructured(intext, length, outfile);
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrencode.1.in
^
|
@@ -1,8 +1,9 @@
-.TH QRENCODE 1 "Sep. 21, 2017" "qrencode @VERSION@"
+.TH QRENCODE 1 "Aug. 28, 2020" "qrencode @VERSION@"
.SH NAME
qrencode \- Encode input data in a QR Code and save as a PNG or EPS image.
.SH SYNOPSIS
.B "qrencode"
+[-o FILENAME]
[OPTION]...
[STRING]
@@ -42,14 +43,14 @@
specify the DPI of the generated PNG. (default=72)
.TP
.PD 0
-.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}
+.B \-t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}
.TP
.PD
-.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8,ANSI256UTF8}
+.B \-\-type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}
specify the type of the generated image. (default=PNG)
.TP
.B \-S, \-\-structured
-make structured symbols. Version must be specified.
+make structured symbols. Version number must be specified with '-v'.
.TP
.B \-k, \-\-kanji
assume that the input text contains kanji (shift-jis).
@@ -63,6 +64,9 @@
.B \-8, \-\-8bit
encode entire data in 8-bit mode. \-k, \-c and \-i will be ignored.
.TP
+.B \-M, \-\-micro
+encode in a Micro QR Code. See MICRO QR CODE for more information.
+.TP
.B \-\-rle
enable run-length encoding for SVG.
.TP
@@ -72,9 +76,6 @@
.B \-\-inline
only useful for SVG output, generates an SVG without the XML tag.
.TP
-.B \-M, \-\-micro
-encode in a Micro QR Code. (experimental)
-.TP
.PD 0
.B \-\-foreground=RRGGBB[AA]
.TP
@@ -84,6 +85,11 @@
6-digit (RGB) or 8-digit (RGBA) form are supported.
Color output support available only in PNG, EPS and SVG.
.TP
+.B \-\-strict\-version
+disable automatic version number adjustment. If the input data is
+too large for the specified version, the program exits with the
+code of 1.
+.TP
.B \-V, \-\-version
display the version number and copyrights of the qrencode.
.TP
@@ -100,6 +106,11 @@
Each higher version number comprises 4 additional modules per side by default.
See http://www.qrcode.com/en/about/version.html for a detailed version list.
+.SH MICRO QR CODE
+With Micro QR Code, You can embed data in a smaller area than with QR Code,
+but the data capacity is strongly limited. The symbol versions range from
+Version 1 to 4.
+
.SH EXAMPLES
.TP
.B qrencode \-l L \-v 1 \-o output.png 'Hello, world!'
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrencode.c
^
|
@@ -445,7 +445,7 @@
errno = EINVAL;
return NULL;
}
- if(input->level > QR_ECLEVEL_H) {
+ if(!(input->level >= QR_ECLEVEL_L && input->level <= QR_ECLEVEL_H)) {
errno = EINVAL;
return NULL;
}
@@ -533,7 +533,7 @@
errno = EINVAL;
return NULL;
}
- if(input->level > QR_ECLEVEL_Q) {
+ if(!(input->level >= QR_ECLEVEL_L && input->level <= QR_ECLEVEL_Q)) {
errno = EINVAL;
return NULL;
}
@@ -653,7 +653,17 @@
QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
{
- return QRcode_encodeStringReal(string, version, level, 1, hint, casesensitive);
+ int i;
+
+ if(version == 0) {
+ version = 1;
+ }
+ for(i = version; i <= MQRSPEC_VERSION_MAX ; i++) {
+ QRcode *code = QRcode_encodeStringReal(string, i, level, 1, hint, casesensitive);
+ if(code != NULL) return code;
+ }
+
+ return NULL;
}
static QRcode *QRcode_encodeDataReal(const unsigned char *data, int length, int version, QRecLevel level, int mqr)
@@ -701,16 +711,36 @@
QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level)
{
- return QRcode_encodeDataReal(data, size, version, level, 1);
+ int i;
+
+ if(version == 0) {
+ version = 1;
+ }
+ for(i = version; i <= MQRSPEC_VERSION_MAX; i++) {
+ QRcode *code = QRcode_encodeDataReal(data, size, i, level, 1);
+ if(code != NULL) return code;
+ }
+
+ return NULL;
}
QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level)
{
+ int i;
+
if(string == NULL) {
errno = EINVAL;
return NULL;
}
- return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 1);
+ if(version == 0) {
+ version = 1;
+ }
+ for(i = version; i <= MQRSPEC_VERSION_MAX; i++) {
+ QRcode *code = QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), i, level, 1);
+ if(code != NULL) return code;
+ }
+
+ return NULL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrencode.h
^
|
@@ -35,8 +35,8 @@
*
* If the input data contains Kanji (Shift-JIS) characters and you want to
* encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint.
- * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data.
- * If you want to encode a whole string in 8 bit mode, you can use
+ * Otherwise, all of non-alphanumeric characters are encoded as 8-bit data.
+ * If you want to encode a whole string in 8-bit mode, you can use
* QRcode_encodeString8bit() instead.
*
* Please note that a C string can not contain NUL characters. If your data
@@ -44,16 +44,16 @@
*
* \subsection encoding-input Encoding a structured data
* You can construct a structured input data manually. If the structure of the
- * input data is known, you can use this way.
+ * input data is known, you can use this method.
* At first, create a ::QRinput object by QRinput_new(). Then add input data
* to the QRinput object by QRinput_append(). Finally call QRcode_encodeInput()
* to encode the QRinput data.
- * You can reuse the QRinput data again to encode it in other symbols with
+ * You can reuse the QRinput object again to encode it in other symbols with
* different parameters.
*
* \section result Result
- * The encoded symbol is resulted as a ::QRcode object. It will contain
- * its version number, width of the symbol and an array represents the symbol.
+ * The encoded symbol is generated as a ::QRcode object. It will contain its
+ * version number, the width of the symbol, and an array represents the symbol.
* See ::QRcode for the details. You can free the object by QRcode_free().
*
* Please note that the version of the result may be larger than specified.
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrinput.c
^
|
@@ -117,7 +117,7 @@
{
QRinput *input;
- if(version < 0 || version > QRSPEC_VERSION_MAX || level > QR_ECLEVEL_H) {
+ if(version < 0 || version > QRSPEC_VERSION_MAX || level < 0 || level > QR_ECLEVEL_H) {
errno = EINVAL;
return NULL;
}
@@ -445,7 +445,7 @@
} else if(entry->size - words * 3 == 2) {
val = (unsigned int)(entry->data[words*3 ] - '0') * 10;
val += (unsigned int)(entry->data[words*3+1] - '0');
- BitStream_appendNum(bstream, 7, val);
+ ret = BitStream_appendNum(bstream, 7, val);
if(ret < 0) return -1;
}
@@ -521,7 +521,7 @@
if(mqr) {
if(version < 2) {
- errno = EINVAL;
+ errno = ERANGE;
return -1;
}
ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_AN);
@@ -583,7 +583,7 @@
if(mqr) {
if(version < 3) {
- errno = EINVAL;
+ errno = ERANGE;
return -1;
}
ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_8);
@@ -659,7 +659,7 @@
if(mqr) {
if(version < 2) {
- errno = EINVAL;
+ errno = ERANGE;
return -1;
}
ret = BitStream_appendNum(bstream, (size_t)(version - 1), MQRSPEC_MODEID_KANJI);
@@ -890,13 +890,17 @@
}
if(mqr) {
- l = QRspec_lengthIndicator(entry->mode, version);
+ l = MQRspec_lengthIndicator(entry->mode, version);
m = version - 1;
bits += l + m;
} else {
l = QRspec_lengthIndicator(entry->mode, version);
m = 1 << l;
- num = (entry->size + m - 1) / m;
+ if(entry->mode == QR_MODE_KANJI) {
+ num = (entry->size/2 + m - 1) / m;
+ } else {
+ num = (entry->size + m - 1) / m;
+ }
bits += num * (MODE_INDICATOR_SIZE + l);
}
@@ -927,9 +931,9 @@
/**
* Estimate the required version number of the symbol.
* @param input input data
- * @return required version number
+ * @return required version number or -1 for failure.
*/
-static int QRinput_estimateVersion(QRinput *input)
+STATIC_IN_RELEASE int QRinput_estimateVersion(QRinput *input)
{
int bits;
int version, prev;
@@ -939,6 +943,9 @@
prev = version;
bits = QRinput_estimateBitStreamSize(input, prev);
version = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
+ if(prev == 0 && version > 1) {
+ version--;
+ }
} while (version > prev);
return version;
@@ -1011,7 +1018,11 @@
prevsize = (int)BitStream_size(bstream);
- words = QRspec_maximumWords(entry->mode, version);
+ if(mqr) {
+ words = MQRspec_maximumWords(entry->mode, version);
+ } else {
+ words = QRspec_maximumWords(entry->mode, version);
+ }
if(words != 0 && entry->size > words) {
st1 = QRinput_List_newEntry(entry->mode, words, entry->data);
if(st1 == NULL) goto ABORT;
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/qrinput.h
^
|
@@ -116,6 +116,7 @@
extern int QRinput_getBitStream(QRinput *input, BitStream *bstream);
extern int QRinput_estimateBitStreamSize(QRinput *input, int version);
extern int QRinput_splitEntry(QRinput_List *entry, int bytes);
+extern int QRinput_estimateVersion(QRinput *input);
extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits);
extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity);
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/split.c
^
|
@@ -257,21 +257,23 @@
int length;
QRencodeMode mode;
- if(*string == '\0') return 0;
-
- mode = Split_identifyMode(string, hint);
- if(mode == QR_MODE_NUM) {
- length = Split_eatNum(string, input, hint);
- } else if(mode == QR_MODE_AN) {
- length = Split_eatAn(string, input, hint);
- } else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
- length = Split_eatKanji(string, input, hint);
- } else {
- length = Split_eat8(string, input, hint);
+ while(*string != '\0') {
+ mode = Split_identifyMode(string, hint);
+ if(mode == QR_MODE_NUM) {
+ length = Split_eatNum(string, input, hint);
+ } else if(mode == QR_MODE_AN) {
+ length = Split_eatAn(string, input, hint);
+ } else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
+ length = Split_eatKanji(string, input, hint);
+ } else {
+ length = Split_eat8(string, input, hint);
+ }
+ if(length == 0) break;
+ if(length < 0) return -1;
+ string += length;
}
- if(length == 0) return 0;
- if(length < 0) return -1;
- return Split_splitString(&string[length], input, hint);
+
+ return 0;
}
static char *dupAndToUpper(const char *str, QRencodeMode hint)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/CMakeLists.txt
^
|
@@ -27,11 +27,21 @@
endif(HAVE_SDL)
if(TARGET Threads::Threads)
+ if(HAVE_SYS_TIME_H)
+ add_definitions(-DHAVE_SYS_TIME_H)
+ endif()
+
+ if(HAVE_TIME_H)
+ add_definitions(-DHAVE_TIME_H)
+ endif()
+
add_executable(prof_qrencode prof_qrencode.c)
target_link_libraries(prof_qrencode common Threads::Threads)
- add_executable(pthread_qrencode pthread_qrencode.c)
- target_link_libraries(pthread_qrencode common Threads::Threads)
+ if(HAVE_PTHREAD_H)
+ add_executable(pthread_qrencode pthread_qrencode.c)
+ target_link_libraries(pthread_qrencode common Threads::Threads)
+ endif()
endif()
MAKE_TEST(test_bitstream)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/Makefile.am
^
|
@@ -11,11 +11,10 @@
pngPROGRAMS = create_frame_pattern create_mqr_frame_pattern
endif
-noinst_PROGRAMS = test_qrinput test_bitstream test_estimatebit \
- test_qrspec test_rs test_qrencode prof_qrencode \
- test_mqrspec test_split test_monkey test_mask test_mmask \
- test_split_urls \
- $(pngPROGRAMS) $(sdlPROGRAMS)
+check_PROGRAMS = test_qrinput test_bitstream test_estimatebit test_qrspec \
+ test_rs test_qrencode test_mqrspec test_split test_mask \
+ test_mmask test_split_urls test_monkey
+noinst_PROGRAMS = $(pngPROGRAMS) $(sdlPROGRAMS) $(check_PROGRAMS) prof_qrencode
noinst_LIBRARIES = libdecoder.a
DECODER_LIBS = libdecoder.a $(LIBICONV)
noinst_HEADERS = common.h rscode.h
@@ -23,6 +22,7 @@
noinst_PROGRAMS += pthread_qrencode
endif
+TESTS = $(check_PROGRAMS)
EXTRA_DIST = test_all.sh test_basic.sh test_configure.sh frame URI_testset.inc CMakeLists.txt
libdecoder_a_SOURCES = decoder.c decoder.h datachunk.c datachunk.h rsecc_decoder.c rsecc_decoder.h
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/common.c
^
|
@@ -51,6 +51,11 @@
return ncmpBin(correct, bstream, len);
}
+void testInit(int tests)
+{
+ printf("1..%d\n", tests);
+}
+
void testStartReal(const char *func, const char *name)
{
tests++;
@@ -58,37 +63,42 @@
testFunc = func;
assertionFailed = 0;
assertionNum = 0;
- printf("_____%d: %s: %s...\n", tests, func, name);
+ //printf("_____%d: %s: %s...\n", tests, func, name);
}
void testEnd(int result)
{
- printf(".....%d: %s: %s, ", tests, testFunc, testName);
if(result) {
- puts("FAILED.");
+ printf("not ok %d %s: %s\n", tests, testFunc, testName);
failed++;
} else {
- puts("PASSED.");
+ printf("ok %d %s: %s\n", tests, testFunc, testName);
}
}
void testFinish(void)
{
- printf(".....%d: %s: %s, ", tests, testFunc, testName);
if(assertionFailed) {
- printf("FAILED. (%d assertions failed.)\n", assertionFailed);
+ printf("not ok %d %s: %s (%d assertions failed.)\n", tests, testFunc, testName, assertionFailed);
failed++;
} else {
- printf("PASSED. (%d assertions passed.)\n", assertionNum);
+ printf("ok %d %s: %s (%d assertions passed.)\n", tests, testFunc, testName, assertionNum);
}
}
-void report()
+void testReport(int expectedTests)
{
printf("Total %d tests, %d fails.\n", tests, failed);
if(failed) exit(-1);
+ if(expectedTests != tests) {
+ printf("WARNING: the number of the executed tests (%d) is not equal to the expecetd (%d).\n", tests, expectedTests);
+ }
}
+int testNum(void)
+{
+ return tests;
+}
void printBinary(unsigned char *data, int length)
{
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/common.h
^
|
@@ -19,12 +19,13 @@
extern const char levelChar[4];
extern const char *modeStr[5];
+void testInit(int tests);
#define testStart(__arg__) (testStartReal(__func__, __arg__))
#define testEndExp(__arg__) (testEnd(!(__arg__)))
void testStartReal(const char *func, const char *name);
void testEnd(int result);
void testFinish(void);
-void report();
+void testReport(int tests);
#define assert_exp(__exp__, ...) \
{assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/prof_qrencode.c
^
|
@@ -1,24 +1,54 @@
#include <stdio.h>
#include <stdlib.h>
+#if HAVE_CONFIG_H
+#include "../config.h"
+#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
-#include <time.h>
+#endif
#include <errno.h>
#include "../qrencode.h"
+#ifdef _MSC_VER
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+static LARGE_INTEGER startTime;
+static LARGE_INTEGER frequency = { .QuadPart = 0 };
+#else
static struct timeval tv;
+#endif
+
static void timerStart(const char *str)
{
printf("%s: START\n", str);
+#ifdef _MSC_VER
+ (void) QueryPerformanceCounter(&startTime);
+#else
gettimeofday(&tv, NULL);
+#endif
}
static void timerStop(void)
{
+#ifdef _MSC_VER
+ LARGE_INTEGER endTime, elapsed;
+ (void) QueryPerformanceCounter(&endTime);
+ if (frequency.QuadPart == 0) {
+ (void) QueryPerformanceFrequency(&frequency);
+ }
+
+ elapsed.QuadPart = endTime.QuadPart - startTime.QuadPart;
+ elapsed.QuadPart *= 1000;
+ elapsed.QuadPart /= frequency.QuadPart;
+
+ printf("STOP: %lld msec\n", elapsed.QuadPart);
+#else
struct timeval tc;
gettimeofday(&tc, NULL);
printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000
+ (tc.tv_usec - tv.tv_usec) / 1000);
+#endif
}
static void prof_ver1to10(void)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/pthread_qrencode.c
^
|
@@ -1,8 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
+#if HAVE_CONFIG_H
+#include "../config.h"
+#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <pthread.h>
-#include <time.h>
#include <errno.h>
#include "../qrencode.h"
@@ -10,20 +14,46 @@
static pthread_t threads[THREADS];
+#ifdef _MSC_VER
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+static LARGE_INTEGER startTime;
+static LARGE_INTEGER frequency = { .QuadPart = 0 };
+#else
static struct timeval tv;
+#endif
+
static void timerStart(const char *str)
{
printf("%s: START\n", str);
+#ifdef _MSC_VER
+ (void) QueryPerformanceCounter(&startTime);
+#else
gettimeofday(&tv, NULL);
+#endif
}
static void timerStop(void)
{
+#ifdef _MSC_VER
+ LARGE_INTEGER endTime, elapsed;
+ (void) QueryPerformanceCounter(&endTime);
+ if (frequency.QuadPart == 0) {
+ (void) QueryPerformanceFrequency(&frequency);
+ }
+
+ elapsed.QuadPart = endTime.QuadPart - startTime.QuadPart;
+ elapsed.QuadPart *= 1000;
+ elapsed.QuadPart /= frequency.QuadPart;
+
+ printf("STOP: %lld msec\n", elapsed.QuadPart);
+#else
struct timeval tc;
gettimeofday(&tc, NULL);
printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000
+ (tc.tv_usec - tv.tv_usec) / 1000);
+#endif
}
static void *encode_ver1to10(void *arg)
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_bitstream.c
^
|
@@ -216,6 +216,8 @@
assert_zero(cmpBin("0101", bstream), "Internal data is incorrect.\n");
testFinish();
+
+ BitStream_free(bstream);
}
static void test_newWithBits_size0(void)
@@ -230,10 +232,14 @@
assert_nonnull(bstream->data, "Internal buffer not allocated.\n");
testFinish();
+
+ BitStream_free(bstream);
}
int main()
{
+ int tests = 11;
+ testInit(tests);
test_null();
test_num();
test_bytes();
@@ -245,8 +251,7 @@
test_append();
test_newWithBits();
test_newWithBits_size0();
-
- report();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_estimatebit.c
^
|
@@ -139,10 +139,35 @@
QRinput_free(gstream);
}
+/* Taken from JISX 0510:2018, p.23 */
+static void test_numbit1_mqr(void)
+{
+ QRinput *stream;
+ char *str = "0123456789012345";
+ int bits;
+
+ testStart("Estimation of Numeric stream for Micro QR Code (16 digits)");
+ stream = QRinput_newMQR(3, QR_ECLEVEL_M);
+ QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str);
+ bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream));
+ assert_equal(bits, 61, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 61);
+ QRinput_free(stream);
+
+ stream = QRinput_newMQR(4, QR_ECLEVEL_M);
+ QRinput_append(stream, QR_MODE_NUM, 16, (const unsigned char *)str);
+ bits = QRinput_estimateBitStreamSize(stream, QRinput_getVersion(stream));
+ assert_equal(bits, 63, "Estimated bit length is wrong: %d, expected: %d.\n", bits, 63);
+ QRinput_free(stream);
+
+ testFinish();
+}
+
int main()
{
gstream = QRinput_new();
+ int tests = 9;
+ testInit(tests);
test_numbit();
test_numbit2();
test_numbit3();
@@ -151,8 +176,8 @@
test_kanji();
test_structure();
test_mix();
-
- report();
+ test_numbit1_mqr();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_mask.c
^
|
@@ -391,6 +391,8 @@
int main(int argc, char **argv)
{
+ int tests = 9;
+ testInit(tests);
test_masks();
test_eval();
test_eval2();
@@ -399,7 +401,7 @@
test_calcN2();
test_calcRunLength();
test_calcN1N3();
- report();
+ testReport(tests);
if(argc > 1) {
print_masks();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_mmask.c
^
|
@@ -141,9 +141,11 @@
int main(int argc, char **argv)
{
+ int tests = 2;
+ testInit(tests);
test_masks();
test_maskEvaluation();
- report();
+ testReport(tests);
if(argc > 1) {
print_masks();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_monkey.c
^
|
@@ -186,11 +186,12 @@
{
int i;
- puts("Monkey test: QRcode_encodeString() - AlphaNumeric string.");
+ testStart("Monkey test: QRcode_encodeString() - AlphaNumeric string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_an(i);
}
+ testEnd(0);
}
@@ -249,11 +250,12 @@
{
int i;
- puts("Monkey test: Split_splitStringToQRinput() - AlphaNumeric string.");
+ testStart("Monkey test: Split_splitStringToQRinput() - AlphaNumeric string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_an(i);
}
+ testEnd(0);
}
static void test_encode_8(int num)
@@ -291,11 +293,12 @@
{
int i;
- puts("Monkey test: QRcode_encodeData() - 8bit char string.");
+ testStart("Monkey test: QRcode_encodeData() - 8bit char string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_8(i);
}
+ testEnd(0);
}
static void test_split_8(int num)
@@ -353,11 +356,12 @@
{
int i;
- puts("Monkey test: Split_splitStringToQRinput() - 8bit char string.");
+ testStart("Monkey test: Split_splitStringToQRinput() - 8bit char string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_8(i);
}
+ testEnd(0);
}
static void test_encode_kanji(int num)
@@ -395,11 +399,12 @@
{
int i;
- puts("Monkey test: QRcode_encodeString() - kanji string.");
+ testStart("Monkey test: QRcode_encodeString() - kanji string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_kanji(i);
}
+ testEnd(0);
}
static void test_split_kanji(int num)
@@ -457,11 +462,12 @@
{
int i;
- puts("Monkey test: Split_splitStringToQRinput() - kanji string.");
+ testStart("Monkey test: Split_splitStringToQRinput() - kanji string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_kanji(i);
}
+ testEnd(0);
}
static void test_split_structure(int num)
@@ -539,17 +545,20 @@
QRinput_free(input);
QRinput_Struct_free(s);
QRcode_List_free(codes);
+
+ return;
}
static void monkey_split_structure(int loop)
{
int i;
- puts("Monkey test: QRinput_splitQRinputToStruct.");
+ testStart("Monkey test: QRinput_splitQRinputToStruct.");
srand(0);
for(i=0; i<loop; i++) {
test_split_structure(i);
}
+ testEnd(0);
}
int main(int argc, char **argv)
@@ -558,6 +567,8 @@
if(argc == 2) {
loop = atoi(argv[1]);
}
+ int tests = 7;
+ testInit(tests);
monkey_split_an(loop);
monkey_encode_an(loop);
monkey_split_8(loop);
@@ -565,6 +576,7 @@
monkey_split_kanji(loop);
monkey_encode_kanji(loop);
monkey_split_structure(loop);
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_mqrspec.c
^
|
@@ -165,11 +165,13 @@
int main(int argc, char **argv)
{
+ int tests = 4;
+ testInit(tests);
test_newFrame();
test_newframe_invalid();
test_format();
test_dataLength();
- report();
+ testReport(tests);
if(argc > 1) {
print_format();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_qrencode.c
^
|
@@ -489,6 +489,34 @@
testFinish();
}
+static void test_encodeVer26Num(void)
+{
+ char data[3284];
+ QRcode *qrcode;
+
+ testStart("Encoding 3283 digits number. (issue #160)");
+
+ memset(data, '0', 3283);
+ data[3283] = '\0';
+ qrcode = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
+ assert_nonnull(qrcode, "(QRcode_encodeString) failed to encode 3283 digits number in level L.\n");
+ assert_equal(qrcode->version, 26, "version number is %d (26 expected)\n", qrcode->version);
+ if(qrcode != NULL) {
+ QRcode_free(qrcode);
+ }
+
+ QRinput *input;
+ QRinput_List *list;
+
+ input = QRinput_new2(0, QR_ECLEVEL_L);
+ Split_splitStringToQRinput(data, input, QR_MODE_8, 0);
+ list = input->head;
+ assert_equal(list->size, 3283, "chunk size is wrong. (%d, 3283 expected)\n", list->size);
+ QRinput_free(input);
+
+ testFinish();
+}
+
static void test_01234567(void)
{
QRinput *stream;
@@ -655,14 +683,14 @@
testStart("Encode too large data for MQR.");
code = QRcode_encodeStringMQR(data[0], 1, QR_ECLEVEL_L, QR_MODE_8, 0);
- assert_null(code, "6 byte length numeric string was accepted to version 1.\n");
- assert_equal(errno, ERANGE, "errno != ERANGE\n");
+ assert_nonnull(code, "6 byte length numeric string should be accepted to version 2 or larger.\n");
+ assert_equal(code->version, 2, "6 byte length numeric string should be accepted to version 2.\n");
code = QRcode_encodeStringMQR(data[1], 2, QR_ECLEVEL_L, QR_MODE_8, 0);
- assert_null(code, "7 byte length alphanumeric string was accepted to version 2.\n");
- assert_equal(errno, ERANGE, "errno != ERANGE\n");
+ assert_nonnull(code, "7 byte length alphanumeric string should be accepted to version 3 or larger.\n");
+ assert_equal(code->version, 3, "7 byte length alphanumeric string should be accepted to version 3.\n");
code = QRcode_encodeString8bitMQR(data[2], 3, QR_ECLEVEL_L);
- assert_null(code, "9 byte length 8bit string was accepted to version 3.\n");
- assert_equal(errno, ERANGE, "errno != ERANGE\n");
+ assert_nonnull(code, "9 byte length 8bit string should be accepted to version 4.\n");
+ assert_equal(code->version, 4, "9 byte length 8bit string should be accepted to version 4.\n");
code = QRcode_encodeString8bitMQR(data[3], 4, QR_ECLEVEL_L);
assert_null(code, "16 byte length 8bit string was accepted to version 4.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
@@ -883,6 +911,43 @@
testFinish();
}
+static void test_invalid_inputMQR(void)
+{
+ QRinput *input;
+ QRcode *code;
+
+ testStart("Testing invalid input (MQR).");
+ input = QRinput_newMQR(1, QR_ECLEVEL_L);
+ QRinput_append(input, QR_MODE_AN, 5, (unsigned char *)"TEST1");
+ input->version = -1;
+ input->level = QR_ECLEVEL_L;
+ code = QRcode_encodeInput(input);
+ assert_null(code, "invalid version(-1) was not checked.\n");
+ if(code != NULL) QRcode_free(code);
+
+ input->version = 5;
+ input->level = QR_ECLEVEL_L;
+ code = QRcode_encodeInput(input);
+ assert_null(code, "invalid version(5) access was not checked.\n");
+ if(code != NULL) QRcode_free(code);
+
+ input->version = 1;
+ input->level = (QRecLevel)(QR_ECLEVEL_H);
+ code = QRcode_encodeInput(input);
+ assert_null(code, "invalid level(H) access was not checked.\n");
+ if(code != NULL) QRcode_free(code);
+
+ input->version = 1;
+ input->level = (QRecLevel)-1;
+ code = QRcode_encodeInput(input);
+ assert_null(code, "invalid level(-1) access was not checked.\n");
+ if(code != NULL) QRcode_free(code);
+
+ QRinput_free(input);
+
+ testFinish();
+}
+
static void test_mqrencode(void)
{
char *str = "MICROQR";
@@ -949,6 +1014,8 @@
int main(int argc, char **argv)
{
+ int tests = 33;
+ testInit(tests);
test_iterate();
test_iterate2();
test_filler();
@@ -961,6 +1028,7 @@
test_encodeNull8();
test_encodeEmpty8();
test_encodeLongData();
+ test_encodeVer26Num();
test_01234567();
test_invalid_input();
test_struct_example();
@@ -978,9 +1046,10 @@
test_encodeTooLongMQR();
test_decodeShortMQR();
test_oddBitCalcMQR();
+ test_invalid_inputMQR();
test_mqrencode();
test_apiversion();
- report();
+ testReport(tests);
if(argc > 1) {
print_filler();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_qrinput.c
^
|
@@ -7,6 +7,50 @@
#include "../split.h"
#include "decoder.h"
+/* taken from the Table 7 of JIS X0510:2018 (pp. 31-34) */
+static int maxCharacterLengths[40][4] = {
+ { 41, 25, 17, 10}, /* ver 1 */
+ { 77, 47, 32, 20}, /* ver 2 */
+ { 127, 77, 53, 32}, /* ver 3 */
+ { 187, 114, 78, 48}, /* ver 4 */
+ { 255, 154, 106, 65}, /* ver 5 */
+ { 322, 195, 134, 82}, /* ver 6 */
+ { 370, 224, 154, 95}, /* ver 7 */
+ { 461, 279, 192, 118}, /* ver 8 */
+ { 552, 335, 230, 141}, /* ver 9 */
+ { 652, 395, 271, 167}, /* ver 10 */
+ { 772, 468, 321, 198}, /* ver 11 */
+ { 883, 535, 367, 226}, /* ver 12 */
+ {1022, 619, 425, 262}, /* ver 13 */
+ {1101, 667, 458, 282}, /* ver 14 */
+ {1250, 758, 520, 320}, /* ver 15 */
+ {1408, 854, 586, 361}, /* ver 16 */
+ {1548, 938, 644, 397}, /* ver 17 */
+ {1725, 1046, 718, 442}, /* ver 18 */
+ {1903, 1153, 792, 488}, /* ver 19 */
+ {2061, 1249, 858, 528}, /* ver 20 */
+ {2232, 1352, 929, 572}, /* ver 21 */
+ {2409, 1460, 1003, 618}, /* ver 22 */
+ {2620, 1588, 1091, 672}, /* ver 23 */
+ {2812, 1704, 1171, 721}, /* ver 24 */
+ {3057, 1853, 1273, 784}, /* ver 25 */
+ {3283, 1990, 1367, 842}, /* ver 26 */
+ {3517, 2132, 1465, 902}, /* ver 27 */
+ {3669, 2223, 1528, 940}, /* ver 28 */
+ {3909, 2369, 1628, 1002}, /* ver 29 */
+ {4158, 2520, 1732, 1066}, /* ver 30 */
+ {4417, 2677, 1840, 1132}, /* ver 31 */
+ {4686, 2840, 1952, 1201}, /* ver 32 */
+ {4965, 3009, 2068, 1273}, /* ver 33 */
+ {5253, 3183, 2188, 1347}, /* ver 34 */
+ {5529, 3351, 2303, 1417}, /* ver 35 */
+ {5836, 3537, 2431, 1496}, /* ver 36 */
+ {6153, 3729, 2563, 1577}, /* ver 37 */
+ {6479, 3927, 2699, 1661}, /* ver 38 */
+ {6743, 4087, 2809, 1729}, /* ver 39 */
+ {7089, 4296, 2953, 1817} /* ver 40 */
+};
+
static int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct)
{
QRinput *input;
@@ -791,6 +835,92 @@
testFinish();
}
+static void fillCharacter(char *dest, char ch, int size)
+{
+ memset(dest, ch, size);
+ dest[size] = '\0';
+}
+
+static void checkEstimatedVersion(int ver, int mode)
+{
+ int estimatedVersion;
+ char data[7200];
+ QRinput *input;
+ QRencodeMode hint;
+ int size1, size2;
+ static char *modeStr[4] = {"numeric", "alphanumeric", "8 bit data", "kanji"};
+ static char ch[4] = {'0', 'A', 'a', '\x92'};
+
+ if(mode == QR_MODE_KANJI) {
+ hint = QR_MODE_KANJI;
+ size1 = maxCharacterLengths[ver - 1][mode] * 2;
+ size2 = size1 + 2;
+ } else {
+ hint = QR_MODE_8;
+ size1 = maxCharacterLengths[ver - 1][mode];
+ size2 = size1 + 1;
+ }
+
+ fillCharacter(data, ch[mode], size1);
+ input = QRinput_new2(0, QR_ECLEVEL_L);
+ Split_splitStringToQRinput(data, input, hint, 1);
+ estimatedVersion = QRinput_estimateVersion(input);
+ assert_equal(estimatedVersion, ver, "Estimated version %d is not equal to the expected version %d for %d %s sequence.\n", estimatedVersion, ver, maxCharacterLengths[ver - 1][mode], modeStr[mode]);
+ QRinput_free(input);
+
+ fillCharacter(data, ch[mode], size2);
+ input = QRinput_new2(0, QR_ECLEVEL_L);
+ Split_splitStringToQRinput(data, input, hint, 1);
+ estimatedVersion = QRinput_estimateVersion(input);
+ assert_equal(estimatedVersion, ver + 1, "Estimated version %d is not equal to the expected version %d for %d %s sequence.\n", estimatedVersion, ver, maxCharacterLengths[ver - 1][mode] + 1, modeStr[mode]);
+ QRinput_free(input);
+}
+
+static void test_estimateVersionBoundaryCheck(void)
+{
+ int ver;
+ testStart("Boundary check of estimateVersion");
+ for(ver = 1; ver < QRSPEC_VERSION_MAX; ver++) {
+ checkEstimatedVersion(ver, QR_MODE_NUM);
+ checkEstimatedVersion(ver, QR_MODE_AN);
+ checkEstimatedVersion(ver, QR_MODE_8);
+ checkEstimatedVersion(ver, QR_MODE_KANJI);
+ }
+ testFinish();
+}
+
+static void test_QRinput_new_invalid(void)
+{
+ testStart("Invalid input to QRinput_new2()");
+ QRinput *input;
+
+ input = QRinput_new2(-1, QR_ECLEVEL_H);
+ assert_null(input, "QRinput_new2() returns non-null for invalid version (-1).\n");
+ assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
+ input = QRinput_new2(41, QR_ECLEVEL_H);
+ assert_null(input, "QRinput_new2() returns non-null for invalid version (41).\n");
+ assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
+ input = QRinput_new2(1, -1);
+ assert_null(input, "QRinput_new2() returns non-null for invalid level (-1).\n");
+ assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
+ input = QRinput_new2(1, 5);
+ assert_null(input, "QRinput_new2() returns non-null for invalid level (5).\n");
+ assert_equal(errno, EINVAL, "Error code is not EINVAL.\n");
+ testFinish();
+}
+
+static void test_QRinput_getErrorCorrectionLevel(void)
+{
+ testStart("Invalid input to QRinput_getErrorCorrectionLevel()");
+ QRinput *input;
+ QRecLevel level;
+
+ input = QRinput_new2(1, QR_ECLEVEL_H);
+ level = QRinput_getErrorCorrectionLevel(input);
+ assert_equal(level, QR_ECLEVEL_H, "QRinput_getErrorCorrectionLevel() fails to return expected level.\n");
+ testFinish();
+}
+
static void test_mqr_new(void)
{
QRinput *input;
@@ -946,6 +1076,9 @@
int main()
{
+ int tests = 42;
+ testInit(tests);
+
test_encodeNumeric();
test_encodeNumeric2();
test_encodeNumeric3();
@@ -976,6 +1109,9 @@
test_parity();
test_parity2();
test_null_free();
+ test_estimateVersionBoundaryCheck();
+ test_QRinput_new_invalid();
+ test_QRinput_getErrorCorrectionLevel();
test_mqr_new();
test_mqr_setversion();
@@ -987,7 +1123,7 @@
test_ECIinvalid();
test_encodeECI();
- report();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_qrspec.c
^
|
@@ -172,7 +172,7 @@
#if 0
/* This test is used to check positions of alignment pattern. See Appendix E
- * (pp.71) of JIS X0510:2004 and compare to the output. Before comment out
+ * (p.71) of JIS X0510:2004 and compare to the output. Before comment out
* this test, change the value of the pattern marker's center dot from 0xa1
* to 0xb1 (QRspec_putAlignmentMarker() : finder).
*/
@@ -216,6 +216,7 @@
int i, c;
unsigned int mask;
+ testStart("Checking version pattern.");
for(version=7; version <= QRSPEC_VERSION_MAX; version++) {
pattern = QRspec_getVersionPattern(version);
if((pattern >> 12) != (unsigned int)version) {
@@ -245,9 +246,10 @@
err++;
}
}
+ testEnd(err);
}
-/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */
+/* See Table 22 (p.45) and Appendix C (p. 65) of JIS X0510:2004 */
static unsigned int levelIndicator[4] = {1, 0, 3, 2};
static unsigned int calcFormatInfo(int mask, QRecLevel level)
{
@@ -298,6 +300,8 @@
int main(int argc, char **argv)
{
+ int tests = 6;
+ testInit(tests);
test_eccTable();
test_eccTable2();
test_newframe();
@@ -305,7 +309,7 @@
//test_alignment();
test_verpat();
test_format();
- report();
+ testReport(tests);
if(argc > 1) {
print_eccTable();
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_rs.c
^
|
@@ -116,10 +116,11 @@
int main()
{
RSECC_decoder_init();
+ int tests = 2;
+ testInit(tests);
test_rscodeexample();
test_allQRSizeAndECCLevel();
-
- report();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_split.c
^
|
@@ -530,6 +530,8 @@
int main()
{
+ int tests = 24;
+ testInit(tests);
test_split1();
test_split2();
test_split3();
@@ -545,8 +547,7 @@
test_splitAn8An();
test_split8An8();
test_split8N8();
-
- report();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/libqrencode/tests/test_split_urls.c
^
|
@@ -83,9 +83,10 @@
int main()
{
+ int tests = 1;
+ testInit(tests);
test_bitstream_length();
-
- report();
+ testReport(tests);
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/plugin.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -33,7 +33,6 @@
#include "HarbourAztecCodeGenerator.h"
#include "HarbourBase32.h"
-#include "HarbourImageProvider.h"
#include "HarbourQrCodeGenerator.h"
#include "HarbourQrCodeImageProvider.h"
#include "HarbourDebug.h"
@@ -149,12 +148,11 @@
{
HDEBUG(aUri);
aEngine->addImageProvider("qrcode", new HarbourQrCodeImageProvider);
- aEngine->addImageProvider("qrshare", new HarbourImageProvider);
// Load translations for share UI
QTranslator* tr = new QTranslator(qApp);
- const QString directory("/usr/share/sailfish-qrshare/translations");
- const QString filename("sailfish-qrshare");
+ const QString filename(QRSHARE_TRANSLATIONS_FILE);
+ const QString directory(QRSHARE_TRANSLATIONS_DIR);
const QString prefix("-");
const QString suffix(".qm");
if (tr->load(QLocale(), filename, prefix, directory, suffix) ||
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/qmlplugin.pro
^
|
@@ -4,13 +4,20 @@
QT += qml quick
PKGCONFIG += glib-2.0
-QMAKE_CXXFLAGS += -Wno-unused-parameter
-QMAKE_CFLAGS += -std=c99 -Wno-sign-compare
+QMAKE_CXXFLAGS += -Wno-unused-parameter -fvisibility=hidden
+QMAKE_CFLAGS += -std=c99 -Wno-sign-compare -fvisibility=hidden
+QMAKE_LFLAGS += -fvisibility=hidden
CONFIG(debug, debug|release) {
DEFINES += DEBUG HARBOUR_DEBUG
}
+include(../config.pri)
+
+DEFINES += \
+ QRSHARE_TRANSLATIONS_FILE=\\\"$$QRSHARE_TRANSLATIONS_FILE\\\" \
+ QRSHARE_TRANSLATIONS_DIR=\\\"$$QRSHARE_TRANSLATIONS_DIR\\\"
+
# Directories
HARBOUR_LIB_DIR = $${_PRO_FILE_PWD_}/harbour-lib
HARBOUR_LIB_INCLUDE = $${HARBOUR_LIB_DIR}/include
@@ -32,18 +39,18 @@
$${HARBOUR_LIB_INCLUDE}/HarbourAztecCodeGenerator.h \
$${HARBOUR_LIB_INCLUDE}/HarbourBase32.h \
$${HARBOUR_LIB_INCLUDE}/HarbourDebug.h \
- $${HARBOUR_LIB_INCLUDE}/HarbourImageProvider.h \
$${HARBOUR_LIB_INCLUDE}/HarbourQrCodeGenerator.h \
$${HARBOUR_LIB_INCLUDE}/HarbourQrCodeImageProvider.h \
+ $${HARBOUR_LIB_INCLUDE}/HarbourSystem.h \
$${HARBOUR_LIB_INCLUDE}/HarbourTask.h \
$${HARBOUR_LIB_INCLUDE}/HarbourTheme.h
SOURCES += \
$${HARBOUR_LIB_SRC}/HarbourAztecCodeGenerator.cpp \
$${HARBOUR_LIB_SRC}/HarbourBase32.cpp \
- $${HARBOUR_LIB_SRC}/HarbourImageProvider.cpp \
$${HARBOUR_LIB_SRC}/HarbourQrCodeGenerator.cpp \
$${HARBOUR_LIB_SRC}/HarbourQrCodeImageProvider.cpp \
+ $${HARBOUR_LIB_SRC}/HarbourSystem.cpp \
$${HARBOUR_LIB_SRC}/HarbourTask.cpp \
$${HARBOUR_LIB_SRC}/HarbourTheme.cpp
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/qmlplugin/qrencode.pro
^
|
@@ -3,11 +3,13 @@
TARGET = qrencode
QT-= gui
+QMAKE_CFLAGS += -fvisibility=hidden
+
SRC_DIR = $${_PRO_FILE_PWD_}/libqrencode
MAJOR_VERSION = 4
-MINOR_VERSION = 0
-MICRO_VERSION = 2
+MINOR_VERSION = 1
+MICRO_VERSION = 1
DEFINES += \
STATIC_IN_RELEASE=static \
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/qml/QRShare.qml
^
|
@@ -2,26 +2,24 @@
import Sailfish.Silica 1.0
import com.monich.qrshare 1.0
-Page {
+Item {
id: page
- property url source
property variant content: ({})
- property string methodId
- property string displayName
- property int accountId
- property string accountName
- property var shareEndDestination
+ property real verticalMargins
+ property bool hideInactiveMenu
+ property alias menuWidth: menu.width
readonly property var generators: [ qrCodeGenerator, aztecCodeGenerator ]
- readonly property string text: content ?
+ readonly property string text:
('data' in content) ? content.data :
- ('status' in content) ? content.status : "" : ""
+ ('status' in content) ? content.status : ""
QrCodeGenerator {
id: qrCodeGenerator
text: page.text
+ ecLevel: QrCodeGenerator.ECLevelLowest
readonly property string name: "QR code"
readonly property string baseName: "qr-code"
//: Placeholder text
@@ -33,6 +31,7 @@
id: aztecCodeGenerator
text: page.text
+ ecLevel: AztecCodeGenerator.ECLevelLowest
readonly property string name: "Aztec"
readonly property string baseName: "aztec-code"
//: Placeholder text
@@ -47,6 +46,8 @@
interval: 500
}
+ Component.onCompleted: view.currentIndex = 0
+
SilicaFlickable {
anchors.fill: parent
@@ -54,6 +55,9 @@
id: menu
visible: view.currentItem && view.currentItem.needPullDownMenu
+ opacity: (active || !hideInactiveMenu) ? 1 : 0
+
+ Behavior on opacity { FadeAnimation { } }
property string savedCode
@@ -72,21 +76,19 @@
onClicked: {
var item = view.currentItem
var code = item.code
- if (QRCodeUtils.saveToGallery(code, "QRShare", item.baseName, Math.min(item.scale, 5))) {
+ if (QRCodeUtils.saveToGallery(code, "QRShare", item.baseName, Math.min(item.scaleFactor, Theme.paddingSmall))) {
menu.savedCode = code
}
}
}
}
- PageHeader { id: header }
-
SilicaListView {
id: view
anchors.centerIn: parent
- height: page.height - 2 * header.height
- width: page.width
+ height: Math.min(parent.width, parent.height - 2 * verticalMargins)
+ width: parent.width
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
@@ -105,7 +107,7 @@
readonly property string baseName: generator.baseName
readonly property bool haveCode: code.length > 0
readonly property bool needPullDownMenu: haveCode && code !== lastSavedCode
- readonly property alias scale: image.n
+ readonly property alias scaleFactor: image.n
Rectangle {
color: "white"
@@ -115,8 +117,6 @@
width: image.width + 2 * Theme.horizontalPageMargin
height: image.height + 2 * Theme.horizontalPageMargin
- readonly property int margins: Math.round((Math.min(Screen.width, Screen.height) - Math.max(width, height))/2)
-
Image {
id: image
@@ -127,7 +127,7 @@
height: sourceSize.height * n
smooth: false
- readonly property int maxDisplaySize: Math.min(Screen.width, Screen.height) - 4 * Theme.horizontalPageMargin
+ readonly property int maxDisplaySize: Math.min(delegate.width - 2 * Theme.horizontalPageMargin, delegate.height) - 4 * Theme.horizontalPageMargin
readonly property int maxSourceSize: Math.max(sourceSize.width, sourceSize.height)
readonly property int n: maxSourceSize ? Math.floor(maxDisplaySize/maxSourceSize) : 0
}
@@ -141,7 +141,9 @@
Behavior on opacity { FadeAnimation { } }
sourceComponent: Item {
Image {
- source: "image://qrshare/" + Qt.resolvedUrl("unhappy.svg") + "?" + Theme.highlightColor
+ id: unhappy
+
+ source: Qt.resolvedUrl("unhappy.svg")
height: Math.max(Theme.itemSizeMedium, Math.min(Theme.itemSizeHuge, label.y - Theme.paddingLarge))
sourceSize.height: height
visible: (y >= 0)
@@ -150,12 +152,38 @@
bottom: label.top
bottomMargin: Theme.paddingLarge
}
+ layer.enabled: true
+ layer.effect: ShaderEffect {
+ property variant src: unhappy
+ property color highlight: Theme.highlightColor
+
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 coord;
+ void main() {
+ coord = qt_MultiTexCoord0;
+ gl_Position = qt_Matrix * qt_Vertex;
+ }"
+ fragmentShader: "
+ varying highp vec2 coord;
+ uniform sampler2D src;
+ uniform lowp vec4 highlight;
+ uniform lowp float qt_Opacity;
+ void main() {
+ lowp vec4 tex = texture2D(src, coord);
+ gl_FragColor = vec4(vec3(dot(tex.rgb,
+ vec3(0.344, 0.5, 0.156))),
+ tex.a) * qt_Opacity * highlight;
+ }"
+ }
}
InfoLabel {
id: label
text: generator.textTooLong
- anchors.verticalCenter: parent.verticalCenter
+ anchors.top: parent.verticalCenter
}
}
}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/qml/QRShareItem.qml
^
|
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Item {
+ property var shareAction
+
+ width: parent.width
+ height: isLandscape ? (Screen.width - Theme.itemSizeLarge - 2 * Theme.paddingLarge) : Screen.width
+
+ property Item orientationComponent
+ readonly property int orientation: orientationComponent ? orientationComponent.orientation : Orientation.None
+ readonly property bool isLandscape: (orientation === Orientation.Landscape || orientation === Orientation.LandscapeInverted)
+
+ onIsLandscapeChanged: console.log(isLandscape, height)
+
+ Component.onCompleted: {
+ var parentItem = parent
+ while (parentItem) {
+ if ('orientation' in parentItem) {
+ orientationComponent = parentItem
+ break
+ }
+ parentItem = parentItem.parent
+ }
+ }
+
+ QRShare {
+ anchors.fill: parent
+ content: (shareAction && 'resources' in shareAction && shareAction.resources.length > 0) ? shareAction.resources[0] : undefined
+ menuWidth: width - 2 * Theme.itemSizeSmall - 4 * Theme.paddingMedium
+ hideInactiveMenu: true
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/qml/QRSharePage.qml
^
|
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Page {
+ property url source
+ property alias content: qrShare.content
+ property string methodId
+ property string displayName
+ property int accountId
+ property string accountName
+ property var shareEndDestination
+
+ PageHeader { id: header }
+
+ QRShare {
+ id: qrShare
+
+ anchors.fill: parent
+ verticalMargins: header.height
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/shareplugin.pro
^
|
@@ -1,19 +1,20 @@
TEMPLATE = lib
TARGET = qrshareplugin
-CONFIG += plugin
+CONFIG += plugin link_pkgconfig
+PKGCONFIG += nemotransferengine-qt5
-NAME = sailfish-qrshare
-QRSHARE_UI_DIR = /usr/share/$$NAME
-QRSHARE_TRANSLATIONS_DIR = $${QRSHARE_UI_DIR}/translations
+include(../config.pri)
-QMAKE_CXXFLAGS += -Wno-unused-parameter
+QMAKE_CXXFLAGS += -Wno-unused-parameter -fvisibility=hidden
+QMAKE_CFLAGS += -fvisibility=hidden
+QMAKE_LFLAGS += -fvisibility=hidden
INCLUDEPATH += \
transferengine
DEFINES += \
QRSHARE_UI_DIR=\\\"$$QRSHARE_UI_DIR\\\" \
- QRSHARE_TRANSLATIONS_FILE=\\\"$$NAME\\\" \
+ QRSHARE_TRANSLATIONS_FILE=\\\"$$QRSHARE_TRANSLATIONS_FILE\\\" \
QRSHARE_TRANSLATIONS_DIR=\\\"$$QRSHARE_TRANSLATIONS_DIR\\\"
CONFIG(debug, debug|release) {
@@ -22,8 +23,7 @@
OTHER_FILES += \
transferengine/mediatransferinterface.h \
- transferengine/transfermethodinfo1.h \
- transferengine/transfermethodinfo2.h \
+ transferengine/transfermethodinfo.h \
transferengine/transferplugininfo.h \
transferengine/transferplugininterface.h
@@ -34,7 +34,6 @@
src/qrsharetransfer.h
SOURCES += \
- src/librpm.c \
src/qrshareplugin.cpp \
src/qrshareplugininfo1.cpp \
src/qrshareplugininfo2.cpp \
@@ -43,11 +42,11 @@
QRSHARE_UI_FILES = \
qrshare.svg \
qml/unhappy.svg \
- qml/QRShare.qml
+ qml/*.qml
OTHER_FILES += $$QRSHARE_UI_FILES
-target.path = /usr/lib/nemo-transferengine/plugins
+target.path = $$[QT_INSTALL_LIBS]/nemo-transferengine/plugins
INSTALLS += target
shareui.files = $$QRSHARE_UI_FILES
@@ -91,11 +90,11 @@
export(qm.files)
}
-LANGUAGES = es fr pl pt ru sv zh_CN hu
+LANGUAGES = cs es fr pl pt ru sv zh_CN hu
-addTrFile($$NAME)
+addTrFile($$QRSHARE_TRANSLATIONS_FILE)
for(l, LANGUAGES) {
- addTrFile($${NAME}-$$l)
+ addTrFile($${QRSHARE_TRANSLATIONS_FILE}-$$l)
}
qm.path = $$QRSHARE_TRANSLATIONS_DIR
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/src/qrshare.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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:
*
@@ -35,7 +35,8 @@
#define QRSHARE_H
#define QRSHARE_PLUGIN_ID "QRShare"
-#define QRSHARE_UI_PATH QRSHARE_UI_DIR "/QRShare.qml"
+#define QRSHARE_PAGE_PATH QRSHARE_UI_DIR "/QRSharePage.qml"
+#define QRSHARE_ITEM_PATH QRSHARE_UI_DIR "/QRShareItem.qml"
#define QRSHARE_ICON_PNG QRSHARE_UI_DIR "/qrshare.png"
#define QRSHARE_ICON_SVG QRSHARE_UI_DIR "/qrshare.svg"
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/src/qrshareplugin.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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,13 +41,67 @@
#include <QLocale>
#include <QDebug>
-#include <rpm/rpmlib.h>
-#include <rpm/header.h>
-#include <rpm/rpmts.h>
-#include <rpm/rpmdb.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+static QVector<uint> getPackageVersion(const char* aPackage)
+{
+ QVector<uint> version;
+ int fds[2];
+ if (pipe(fds) == 0) {
+ pid_t pid = fork();
+ if (!pid) {
+ const char* argv[6];
+ argv[0] = "rpm";
+ argv[1] = "-q";
+ argv[2] = "--qf";
+ argv[3] = "%{version}";
+ argv[4] = aPackage;
+ argv[5] = NULL;
+ while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
+ execvp(argv[0], (char**)argv);
+ exit(1);
+ }
+ 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) {
+ const char* v = out.constData();
+ qDebug() << aPackage << v;
+ const QStringList parts(QString(v).split('.', QString::SkipEmptyParts));
+ const int n = qMin(parts.count(),3);
+ for (int i = 0; i < n; i++) {
+ const QString part(parts.at(i));
+ bool ok = false;
+ int val = part.toUInt(&ok);
+ if (ok) {
+ version.append(val);
+ } else {
+ break;
+ }
+ }
+ }
+ waitpid(pid, NULL, 0);
+ close(fds[0]);
+ }
+ return version;
+}
QRSharePlugin::QRSharePlugin() :
- iCreatePluginInfoFunc(QRShareCreatePluginInfo2)
+ iCreatePluginInfoFunc(QRShareCreatePluginInfo2OutOfProcess)
{
// Load translations
QTranslator* tr = new QTranslator(this);
@@ -65,27 +119,18 @@
}
// Figure out which version of plugin API is expected from us
- if (rpmReadConfigFiles(NULL, NULL) == 0) {
- const char* name = "nemo-transferengine-qt5";
- rpmts ts = rpmtsCreate();
- if (ts) {
- rpmdbMatchIterator mi = rpmtsInitIterator(ts, RPMDBI_NAME, name, 0);
- if (mi) {
- Header h = rpmdbNextIterator(mi);
- if (h) {
- const char* v = headerGetString(h, RPMTAG_VERSION);
- if (v) {
- qDebug() << name << v;
- // API break at 0.2.0
- if (v[0] == '0' && v[1] == '.' && v[2] < '2') {
- iCreatePluginInfoFunc = QRShareCreatePluginInfo1;
- }
- }
- }
- rpmdbFreeIterator(mi);
- }
+ // Detect native transferengine plugin API break
+ QVector<uint> v = getPackageVersion("nemo-transferengine-qt5");
+ // API break at 0.2.0
+ if (v.count() >= 2 && v.at(0) == 0 && v.at(1) < 2) {
+ iCreatePluginInfoFunc = QRShareCreatePluginInfo1;
+ } else {
+ // Detect QML API break
+ v = getPackageVersion("declarative-transferengine-qt5");
+ // API break at 0.4.0
+ if (v.count() >= 2 && v.at(0) == 0 && v.at(1) < 4) {
+ iCreatePluginInfoFunc = QRShareCreatePluginInfo2InProcess;
}
- rpmtsFree(ts);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/src/qrshareplugininfo.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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:
*
@@ -37,6 +37,7 @@
class TransferPluginInfo;
TransferPluginInfo* QRShareCreatePluginInfo1();
-TransferPluginInfo* QRShareCreatePluginInfo2();
+TransferPluginInfo* QRShareCreatePluginInfo2InProcess();
+TransferPluginInfo* QRShareCreatePluginInfo2OutOfProcess();
#endif // QRSHARE_PLUGIN_INFO_H
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/src/qrshareplugininfo1.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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:
*
@@ -31,11 +31,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "qrshare.h"
-#include "qrshareplugininfo.h"
-
-#include "transfermethodinfo1.h"
+#define TRANSFER_METHOD_INFO_VERSION 1
+#include "transfermethodinfo.h"
#include "transferplugininfo.h"
+#include "qrshareplugininfo.h"
+#include "qrshare.h"
class QRSharePluginInfo1 : public TransferPluginInfo {
public:
@@ -57,7 +57,7 @@
//% "QR Share"
info.displayName = qtTrId("qrshare-display_name");
info.methodId = QRSHARE_PLUGIN_ID;
- info.shareUIPath = QRSHARE_UI_PATH;
+ info.shareUIPath = QRSHARE_PAGE_PATH;
info.capabilitities.append("text/*");
iInfoList.append(info);
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/src/qrshareplugininfo2.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 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:
*
@@ -31,18 +31,18 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "qrshare.h"
-#include "qrshareplugininfo.h"
-
-#include "transfermethodinfo2.h"
+#define TRANSFER_METHOD_INFO_VERSION 2
+#include "transfermethodinfo.h"
#include "transferplugininfo.h"
+#include "qrshareplugininfo.h"
+#include "qrshare.h"
#include <QFileInfo>
#include <QUrl>
class QRSharePluginInfo2 : public TransferPluginInfo {
public:
- QRSharePluginInfo2();
+ QRSharePluginInfo2(const char* aQmlPath);
QList<TransferMethodInfo> info() const Q_DECL_OVERRIDE;
void query() Q_DECL_OVERRIDE;
@@ -52,7 +52,7 @@
QList<TransferMethodInfo> iInfoList;
};
-QRSharePluginInfo2::QRSharePluginInfo2()
+QRSharePluginInfo2::QRSharePluginInfo2(const char* aQmlPath)
{
TransferMethodInfo info;
QFileInfo png(QRSHARE_ICON_PNG);
@@ -61,7 +61,7 @@
//% "QR Share"
info.displayName = qtTrId("qrshare-display_name");
info.methodId = QRSHARE_PLUGIN_ID;
- info.shareUIPath = QRSHARE_UI_PATH;
+ info.shareUIPath = aQmlPath;
info.capabilitities.append("text/*");
info.accountIcon = QUrl::fromLocalFile(png.exists() ?
png.absoluteFilePath() : QString(QRSHARE_ICON_SVG)).toString();
@@ -84,7 +84,14 @@
return true;
}
-TransferPluginInfo* QRShareCreatePluginInfo2()
+TransferPluginInfo* QRShareCreatePluginInfo2InProcess()
+{
+ // In-process sharing
+ return new QRSharePluginInfo2(QRSHARE_PAGE_PATH);
+}
+
+TransferPluginInfo* QRShareCreatePluginInfo2OutOfProcess()
{
- return new QRSharePluginInfo2;
+ // Out-of-process sharing (Sailfish OS >= 4.2.0)
+ return new QRSharePluginInfo2(QRSHARE_ITEM_PATH);
}
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/transferengine/transfermethodinfo.h
^
|
@@ -0,0 +1,58 @@
+#ifndef TRANSFERMETHODINFO_H
+#define TRANSFERMETHODINFO_H
+
+#include <QString>
+#include <QStringList>
+
+#if TRANSFER_METHOD_INFO_VERSION == 1
+# define TransferMethodInfo TransferMethodInfo1
+#elif TRANSFER_METHOD_INFO_VERSION == 2
+# include <QVariantHash>
+# define TransferMethodInfo TransferMethodInfo2
+#else
+# error "Need to define TRANSFER_METHOD_INFO_VERSION"
+#endif
+
+class TransferMethodInfo {
+public:
+ inline TransferMethodInfo() : accountId(0) {}
+ inline TransferMethodInfo &operator=(const TransferMethodInfo &other) {
+ displayName = other.displayName;
+ userName = other.userName;
+ methodId = other.methodId;
+ shareUIPath = other.shareUIPath;
+ capabilitities = other.capabilitities;
+ accountId = other.accountId;
+#if TRANSFER_METHOD_INFO_VERSION > 1
+ accountIcon = other.accountIcon;
+ hints = other.hints;
+#endif
+ return *this;
+ }
+ inline TransferMethodInfo(const TransferMethodInfo &other) :
+ displayName(other.displayName),
+ userName(other.userName),
+ methodId(other.methodId),
+ shareUIPath(other.shareUIPath),
+ capabilitities(other.capabilitities),
+ accountId(other.accountId) {
+#if TRANSFER_METHOD_INFO_VERSION > 1
+ accountIcon = other.accountIcon;
+ hints = other.hints;
+#endif
+ }
+ inline ~TransferMethodInfo() {}
+
+ QString displayName;
+ QString userName;
+ QString methodId;
+ QString shareUIPath;
+ QStringList capabilitities;
+ quint32 accountId;
+#if TRANSFER_METHOD_INFO_VERSION > 1
+ QString accountIcon;
+ QVariantHash hints;
+#endif
+};
+
+#endif // TRANSFERMETHODINFO_H
|
[-]
[+]
|
Added |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/translations/sailfish-qrshare-cs.ts
^
|
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="cs">
+<context>
+ <name></name>
+ <message id="qrshare-display_name">
+ <source>QR Share</source>
+ <extracomment>Plugin display name</extracomment>
+ <translation>Vygenerovat QR kód</translation>
+ </message>
+ <message id="qrshare-menu-save_to_gallery">
+ <source>Save to Gallery</source>
+ <extracomment>Pulley menu item</extracomment>
+ <translation>Uložit do Gallerie</translation>
+ </message>
+ <message id="qrshare-placeholder-no_text">
+ <source>Nothing to share.</source>
+ <extracomment>Placeholder text</extracomment>
+ <translation>Nic ke sdílení.</translation>
+ </message>
+ <message id="qrshare-placeholder-qrcode-too_long">
+ <source>Text is too long for QR code.</source>
+ <extracomment>Placeholder text</extracomment>
+ <translation>Text je příliš dlouhý pro QR kód.</translation>
+ </message>
+ <message id="qrshare-placeholder-aztec-too_long">
+ <source>Text is too long for Aztec code.</source>
+ <extracomment>Placeholder text</extracomment>
+ <translation>Text je příliš dlouhý pro Aztec kód.</translation>
+ </message>
+</context>
+</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:sailfish-qrshare-1.1.2.tar.gz/shareplugin/translations/sailfish-qrshare-es.ts
^
|
@@ -26,7 +26,7 @@
<message id="qrshare-placeholder-aztec-too_long">
<source>Text is too long for Aztec code.</source>
<extracomment>Placeholder text</extracomment>
- <translation type="unfinished">El texto es demasiado largo para el código Aztec.</translation>
+ <translation>El texto es demasiado largo para el código Aztec.</translation>
</message>
</context>
</TS>
|