[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-mmslog.git</param>
<param name="branch">master</param>
- <param name="revision">1.0.15</param>
+ <param name="revision">1.0.16</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Deleted |
_service:tar_git:harbour-mmslog-1.0.15.tar.bz2/src/org.nemo.transferengine.xml
^
|
@@ -1,12 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<node name="/org/nemo/transferengine">
- <interface name="org.nemo.transferengine">
- <method name="transferMethods">
- <arg name="methods" type="a(ssssasi)" direction="out" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="TransferMethodInfoList"/>
- </method>
- <signal name="transferMethodListChanged" />
- </interface>
-</node>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/.gitmodules
^
|
@@ -1,9 +1,12 @@
-[submodule "src/libdbuslog"]
+[submodule "libdbuslog"]
path = src/libdbuslog
- url = https://git.merproject.org/mer-core/libdbuslog.git
-[submodule "src/libglibutil"]
+ url = https://github.com/monich/libdbuslog.git
+[submodule "libglibutil"]
path = src/libglibutil
- url = https://git.merproject.org/mer-core/libglibutil.git
+ url = https://github.com/monich/libglibutil.git
[submodule "harbour-lib"]
path = src/harbour-lib
url = https://github.com/monich/harbour-lib.git
+[submodule "libdbusaccess"]
+ path = src/libdbusaccess
+ url = https://github.com/monich/libdbusaccess.git
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/harbour-mmslog.desktop
^
|
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
-Name=MMS Logger
-Name[ru]=Регистратор
+Name=MMS Log
+Name[ru]=MMS Лог
X-Nemo-Application-Type=silica-qt5
Icon=harbour-mmslog
Exec=harbour-mmslog
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/harbour-mmslog.pro
^
|
@@ -32,6 +32,10 @@
LIBGLIBUTIL_SRC = $${LIBGLIBUTIL}/src
LIBGLIBUTIL_INCLUDE = $${LIBGLIBUTIL}/include
+LIBDBUSACCESS = src/libdbusaccess
+LIBDBUSACCESS_SRC = $${LIBDBUSACCESS}/src
+LIBDBUSACCESS_INCLUDE = $${LIBDBUSACCESS}/include
+
LIBDBUSLOG = src/libdbuslog
LIBDBUSLOG_COMMON = $${LIBDBUSLOG}/common
LIBDBUSLOG_COMMON_SRC = $${LIBDBUSLOG_COMMON}/src
@@ -50,6 +54,10 @@
$${LIBDBUSLOG_CLIENT_SRC}/dbuslog_receiver.c
SOURCES += \
+ $${LIBDBUSACCESS_SRC}/dbusaccess_cred.c \
+ $${LIBDBUSACCESS_SRC}/dbusaccess_peer.c
+
+SOURCES += \
$${LIBGLIBUTIL_SRC}/gutil_log.c \
$${LIBGLIBUTIL_SRC}/gutil_misc.c \
$${LIBGLIBUTIL_SRC}/gutil_ring.c \
@@ -72,6 +80,7 @@
$${HARBOUR_LIB_INCLUDE} \
$${LIBDBUSLOG_COMMON_INCLUDE} \
$${LIBDBUSLOG_CLIENT_INCLUDE} \
+ $${LIBDBUSACCESS_INCLUDE} \
$${LIBGLIBUTIL_INCLUDE}
HEADERS += \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/LICENSE
^
|
@@ -1,7 +1,7 @@
Copyright (C) 2015-2018 Jolla Ltd.
Copyright (C) 2015-2018 Slava Monich <slava@monich.com>
-You may use this file under the terms of the BSD license as follows:
+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
@@ -13,9 +13,9 @@
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
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/README
^
|
@@ -0,0 +1,14 @@
+Reusable components for Jolla harbour apps
+==========================================
+
+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
+probably incompatible with older versions.
+
+The easiest way to use this code in your project is to add this repo
+as a git submodule to your project and add the files you need to your
+.pro file.
+
+This repository is always work in progress, don't expect any tags,
+formal releases or anything like that.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/harbour-lib.pro
^
|
@@ -19,11 +19,14 @@
}
SOURCES += \
+ src/HarbourBase32.cpp \
src/HarbourDisplayBlanking.cpp \
src/HarbourJson.cpp \
src/HarbourLib.cpp \
src/HarbourMce.cpp \
+ src/HarbourOrganizeListModel.cpp \
src/HarbourSigChildHandler.cpp \
+ src/HarbourSingleImageProvider.cpp \
src/HarbourSystemState.cpp \
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
@@ -33,16 +36,20 @@
greaterThan(QT_MAJOR_VERSION, 4) {
SOURCES += \
src/HarbourImageProvider.cpp \
- src/HarbourPluginLoader.cpp
+ src/HarbourPluginLoader.cpp \
+ src/HarbourTheme.cpp
}
INCLUDEPATH += include
PUBLIC_HEADERS += \
+ include/HarbourBase32.h \
include/HarbourDebug.h \
include/HarbourDisplayBlanking.h \
include/HarbourJson.h \
include/HarbourLib.h \
+ include/HarbourOrganizeListModel.h \
include/HarbourSigChildHandler.h \
+ include/HarbourSingleImageProvider.h \
include/HarbourSystemState.h \
include/HarbourTask.h \
include/HarbourTemporaryFile.h \
@@ -52,7 +59,9 @@
greaterThan(QT_MAJOR_VERSION, 4) {
PUBLIC_HEADERS += \
include/HarbourImageProvider.h \
- include/HarbourPluginLoader.h
+ include/HarbourPluginLoader.h \
+ include/HarbourTheme.h
+OTHER_FILES += qml/*.qml
}
HEADERS += \
@@ -61,6 +70,7 @@
OTHER_FILES += \
LICENSE \
+ README \
rpm/harbour-lib-devel.spec
headers.path = $$INSTALL_ROOT$$PREFIX/include/$$TARGET
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourBase32.h
^
|
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_IMAGE_BASE32_H
+#define HARBOUR_IMAGE_BASE32_H
+
+#include <QString>
+#include <QByteArray>
+
+class HarbourBase32 {
+ class Private;
+ HarbourBase32();
+public:
+ static QByteArray fromBase32(QString aBase32);
+ static QString toBase32(QByteArray aBinary, bool aLowerCase = true);
+ static bool isValidBase32(QString aBase32);
+};
+
+#endif // HARBOUR_IMAGE_BASE32_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourDisplayBlanking.h
^
|
@@ -8,15 +8,15 @@
* 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
@@ -38,8 +38,10 @@
#include <QString>
#include <QSharedPointer>
-class HarbourDisplayBlanking: public QObject
-{
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourDisplayBlanking: public QObject {
Q_OBJECT
Q_PROPERTY(bool paused READ paused NOTIFY pausedChanged)
Q_PROPERTY(bool pauseAllowed READ pauseAllowed NOTIFY pauseAllowedChanged)
@@ -49,6 +51,8 @@
explicit HarbourDisplayBlanking(QObject* aParent = NULL);
~HarbourDisplayBlanking();
+ // Callback for qmlRegisterSingletonType<HarbourDisplayBlanking>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
static QSharedPointer<HarbourDisplayBlanking> sharedInstance();
bool paused() const;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourOrganizeListModel.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_ORGANIZE_LIST_MODEL_H
+#define HARBOUR_ORGANIZE_LIST_MODEL_H
+
+#include <QtQml>
+#include <QSortFilterProxyModel>
+
+// This model helps to implement rearranging list items by dragging.
+// When drag starts, QML sets dragIndex property and then updates
+// dragPos when with the popsition of the dragged list item. When
+// drag is finished, QML sets dragIndex to -1 and the model calls
+// moveRow() on the underlying (source) model, to finish the move.
+
+class HarbourOrganizeListModel : public QSortFilterProxyModel {
+ Q_OBJECT
+ Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelChanged)
+ Q_PROPERTY(int dragIndex READ dragIndex WRITE setDragIndex NOTIFY dragIndexChanged)
+ Q_PROPERTY(int dragPos READ dragPos WRITE setDragPos NOTIFY dragPosChanged)
+
+public:
+ HarbourOrganizeListModel(QObject* aParent = NULL);
+ ~HarbourOrganizeListModel();
+
+ void setSourceModelObject(QObject* aModel);
+
+ int dragIndex() const;
+ void setDragIndex(int aIndex);
+
+ int dragPos() const;
+ void setDragPos(int aPos);
+
+ // QAbstractProxyModel
+ QModelIndex mapToSource(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+ QModelIndex mapFromSource(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void sourceModelChanged();
+ void dragIndexChanged();
+ void dragPosChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourOrganizeListModel)
+
+#endif // HARBOUR_ORGANIZE_LIST_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourQrCodeGenerator.h
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_QRCODE_GENERATOR_H
+#define HARBOUR_QRCODE_GENERATOR_H
+
+#include <QtQml>
+
+class HarbourQrCodeGenerator : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QString code READ code NOTIFY codeChanged)
+ Q_PROPERTY(QString qrcode READ code NOTIFY codeChanged)
+ Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+
+public:
+ HarbourQrCodeGenerator(QObject* aParent = Q_NULLPTR);
+
+ QString text() const;
+ void setText(QString aValue);
+
+ QString code() const;
+ bool running() const;
+
+ Q_INVOKABLE static QByteArray generate(QString aText);
+
+ // Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+Q_SIGNALS:
+ void textChanged();
+ void codeChanged();
+ void runningChanged();
+
+private:
+ class Task;
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourQrCodeGenerator)
+
+#endif // HARBOUR_QRCODE_GENERATOR_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourQrCodeImageProvider.h
^
|
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_QRCODE_IMAGEPROVIDER_H
+#define HARBOUR_QRCODE_IMAGEPROVIDER_H
+
+#include <QImage>
+#include <QQuickImageProvider>
+
+class HarbourQrCodeImageProvider : public QQuickImageProvider {
+public:
+ HarbourQrCodeImageProvider() : QQuickImageProvider(Image) {}
+
+ static const QColor DEFAULT_COLOR; // Qt::black
+ static const QColor DEFAULT_BACKGROUND; // Qt::transparent
+
+ static QImage createImage(QByteArray aBits, QColor aColor = DEFAULT_COLOR,
+ QColor aBackground = DEFAULT_BACKGROUND);
+
+ QImage requestImage(const QString& aId, QSize* aSize,
+ const QSize& aRequested) Q_DECL_OVERRIDE;
+};
+
+#endif // HARBOUR_QRCODE_IMAGEPROVIDER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourSingleImageProvider.h
^
|
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_SINGLE_IMAGE_PROVIDER_H
+#define HARBOUR_SINGLE_IMAGE_PROVIDER_H
+
+#include <QImage>
+#include <QObject>
+#include <QQmlParserStatus>
+
+class HarbourSingleImageProvider : public QObject, public QQmlParserStatus {
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
+ Q_PROPERTY(QString source READ source NOTIFY sourceChanged)
+
+public:
+ HarbourSingleImageProvider(QObject* aParent = Q_NULLPTR);
+
+ QImage image() const;
+ void setImage(QImage aImage);
+
+ QString source() const;
+
+ Q_INVOKABLE void clear();
+
+ // QQmlParserStatus
+ void classBegin() Q_DECL_OVERRIDE;
+ void componentComplete() Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void imageChanged();
+ void sourceChanged();
+
+private:
+ class Private;
+ class ImageProvider;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SINGLE_IMAGE_PROVIDER_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourSystemState.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2016 Jolla Ltd.
- * Copyright (C) 2015-2017 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2018 Jolla Ltd.
+ * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* 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
@@ -38,6 +38,9 @@
#include <QString>
#include <QSharedPointer>
+class QQmlEngine;
+class QJSEngine;
+
class HarbourSystemState: public QObject
{
Q_OBJECT
@@ -63,6 +66,8 @@
explicit HarbourSystemState(QObject* aParent = NULL);
~HarbourSystemState();
+ // Callback for qmlRegisterSingletonType<HarbourSystemState>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
static QSharedPointer<HarbourSystemState> sharedInstance();
QString displayStatus() const;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourTask.h
^
|
@@ -74,6 +74,7 @@
private Q_SLOTS:
void onAboutToQuit();
void onRunFinished();
+ void onTargetDestroyed(QObject* aObject);
private:
class Private;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourTheme.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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_THEME_H
+#define HARBOUR_THEME_H
+
+#include <QObject>
+#include <QColor>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourTheme : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(ColorScheme colorScheme READ colorScheme NOTIFY colorSchemeChanged)
+ Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryColorChanged)
+ Q_PROPERTY(bool lightOnDark READ lightOnDark NOTIFY colorSchemeChanged)
+ Q_PROPERTY(bool darkOnLight READ darkOnLight NOTIFY colorSchemeChanged)
+ Q_ENUMS(ColorScheme)
+
+public:
+ class Private;
+
+ enum ColorScheme {
+ LightOnDark,
+ DarkOnLight
+ };
+
+ explicit HarbourTheme(QObject* aParent = NULL);
+
+ ~HarbourTheme();
+
+ // Callback for qmlRegisterSingletonType<HarbourTheme>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ QColor primaryColor() const;
+ ColorScheme colorScheme() const;
+ bool lightOnDark() const;
+ bool darkOnLight() const;
+
+Q_SIGNALS:
+ void colorSchemeChanged();
+ void primaryColorChanged();
+
+private:
+ QObject* iPrivate;
+};
+
+#endif // HARBOUR_THEME_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/include/HarbourTransferMethodsModel.h
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2019 Jolla Ltd.
+ * Copyright (C) 2016-2019 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,33 +11,37 @@
* 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
+ * 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_TRANSFER_METHODS_MODEL_H
#define HARBOUR_TRANSFER_METHODS_MODEL_H
#include "HarbourTransferMethodInfo.h"
+
#include <QLocale>
#include <QRegExp>
class QTranslator;
+class QQmlEngine;
+class QJSEngine;
class HarbourTransferMethodsModel: public QAbstractListModel
{
@@ -58,9 +62,12 @@
};
public:
- explicit HarbourTransferMethodsModel(QObject* aParent = NULL);
+ explicit HarbourTransferMethodsModel(QObject* aParent = Q_NULLPTR);
~HarbourTransferMethodsModel();
+ // Callback for qmlRegisterSingletonType<HarbourTransferMethodsModel>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
static bool loadTranslations(QTranslator* aTranslator, QLocale aLocale);
int count() const;
@@ -68,11 +75,9 @@
void setFilter(QString filter);
bool accountIconSupported() const;
- int rowCount(const QModelIndex& aParent) const;
- QVariant data(const QModelIndex& aIndex, int aRole) const;
-
-protected:
- QHash<int,QByteArray> roleNames() const;
+ 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();
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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.2
+import Sailfish.Silica 1.0
+
+Item {
+ id: badge
+
+ property real maxWidth
+ property alias text: label.text
+ readonly property real radius: height/2
+
+ width: maxWidth > 0 ? Math.max(label.paintedWidth + radius, height) : height
+ height: Theme.itemSizeSmall/2
+ visible: opacity > 0
+ opacity: text.length ? 1 : 0
+
+ Behavior on opacity { FadeAnimator {} }
+
+ Rectangle {
+ id: background
+
+ anchors.fill: parent
+ color: Theme.rgba(Theme.primaryColor, 0.2)
+ radius: badge.radius
+ }
+
+ HarbourFitLabel {
+ id: label
+
+ font.bold: true
+ width: Math.max((maxWidth > 0 ? maxWidth : parent.width) - radius, height)
+ height: Math.floor(parent.height - radius/2)
+ anchors.centerIn: background
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourFitLabel.qml
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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.2
+import Sailfish.Silica 1.0
+
+Label {
+ property int minFontSize: Theme.fontSizeTiny
+ property int maxFontSize: Theme.fontSizeMedium
+ property int refitting
+
+ smooth: true
+ visible: opacity > 0
+ color: Theme.highlightColor
+ anchors.margins: Theme.paddingMedium
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+
+ Behavior on opacity { FadeAnimator {} }
+
+ Component.onCompleted: refitText()
+
+ onWidthChanged: refitText()
+ onHeightChanged: refitText()
+ onTextChanged: refitText()
+ onMaxFontSizeChanged: refitText()
+ onMinFontSizeChanged: refitText()
+
+ function refitText() {
+ refitting++
+ if (refitting == 1 && paintedHeight > 0 && paintedWidth > 0) {
+ if (font.pixelSize % 2) font.pixelSize++
+ while (paintedWidth > width || paintedHeight > height) {
+ if ((font.pixelSize -= 2) <= minFontSize)
+ break
+ }
+ while (paintedWidth < width && paintedHeight < height) {
+ font.pixelSize += 2
+ }
+ font.pixelSize -= 2
+ if (font.pixelSize >= maxFontSize) {
+ font.pixelSize = maxFontSize
+ return
+ }
+ }
+ refitting--
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourHorizontalSwipeHint.qml
^
|
@@ -0,0 +1,53 @@
+import QtQuick 2.2
+import Sailfish.Silica 1.0
+
+Item {
+ id: hint
+
+ anchors.fill: parent
+
+ property bool swipeRight
+ property bool hintEnabled
+ property alias text: label.text
+ property alias hintDelay: hintDelayTimer.interval
+ readonly property bool hintRunning: hintDelayTimer.running || touchInteractionHint.running || label.opacity > 0
+
+ signal hintShown()
+
+ function showHint() {
+ touchInteractionHint.start()
+ }
+
+ onHintEnabledChanged: {
+ if (hint.hintEnabled) {
+ hintDelayTimer.restart()
+ } else {
+ hintDelayTimer.stop()
+ }
+ }
+
+ Component.onCompleted: if (hint.hintEnabled) hintDelayTimer.start()
+
+ InteractionHintLabel {
+ id: label
+
+ anchors.bottom: parent.bottom
+ opacity: touchInteractionHint.running ? 1.0 : 0.0
+ Behavior on opacity { FadeAnimator { duration: 1000 } }
+ }
+
+ TouchInteractionHint {
+ id: touchInteractionHint
+
+ direction: swipeRight ? TouchInteraction.Right : TouchInteraction.Left
+ anchors.verticalCenter: parent.verticalCenter
+ onRunningChanged: if (!running) hint.hintShown()
+ }
+
+ Timer {
+ id: hintDelayTimer
+
+ interval: 1000
+ onTriggered: showHint()
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourIconTextButton.qml
^
|
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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 alias iconSource: image.imageSource
+ property alias text: label.text
+
+ readonly property bool _showPress: highlighted || pressTimer.running
+
+ onPressedChanged: {
+ if (pressed) {
+ pressTimer.start()
+ }
+ }
+
+ onCanceled: pressTimer.stop()
+
+ width: Math.max(image.width, label.width)
+ height: image.height + label.height
+
+ Image {
+ 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 ""
+ }
+ }
+ sourceSize: Qt.size(Theme.itemSizeSmall, Theme.itemSizeSmall)
+ source: _showPress ? highlightSource : imageSource
+ opacity: parent.enabled ? 1.0 : 0.4
+ anchors {
+ top: parent.top
+ horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Label {
+ id: label
+
+ height: text.length ? (implicitHeight + Theme.paddingMedium) : 0
+ opacity: parent.enabled ? 1.0 : 0.4
+ anchors {
+ top: image.bottom
+ horizontalCenter: parent.horizontalCenter
+ }
+ wrapMode: Text.Wrap
+ font.pixelSize: Theme.fontSizeExtraSmall
+ color: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ }
+
+ Timer {
+ id: pressTimer
+
+ interval: ('minimumPressHighlightTime' in Theme) ? Theme.minimumPressHighlightTime : 64
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourPasswordInputField.qml
^
|
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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
+
+TextField {
+ id: field
+
+ property bool showEchoModeToggle: activeFocus
+ property int passwordEchoMode: TextInput.Password
+
+ property bool _usePasswordEchoMode: true
+ property int _buttonLeftMargin: Theme.paddingLarge
+
+ width: (parent ? parent.width : Screen.width) - 2*x
+ textRightMargin: textMargin
+ echoMode: _usePasswordEchoMode ? passwordEchoMode : TextInput.Normal
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+
+ //: Default placeholder for password field
+ //% "Password"
+ placeholderText: qsTrId("components-ph-password")
+
+ //: Default label for password field
+ //% "Password"
+ label: qsTrId("components-la-password")
+
+ function requestFocus() {
+ focusOutBehavior = FocusBehavior.KeepFocus
+ forceActiveFocus()
+ keepFocusTimer.start()
+ }
+
+ Connections {
+ target: Qt.application
+ onActiveChanged: {
+ if (!Qt.application.active) {
+ _usePasswordEchoMode = true
+ }
+ }
+ }
+
+ Timer {
+ id: keepFocusTimer
+
+ interval: 500
+ onTriggered: field.focusOutBehavior = FocusBehavior.ClearItemFocus
+ }
+
+ states: State {
+ name: "showToggle"
+ when: field.showEchoModeToggle
+ PropertyChanges {
+ target: field
+ textRightMargin: field._buttonLeftMargin/2 + passwordVisibilityButton.width + field.textMargin
+ }
+ PropertyChanges {
+ target: passwordVisibilityButton
+ opacity: 1
+ enabled: true
+ }
+ }
+
+ transitions: Transition {
+ from: ""
+ to: "showToggle"
+ reversible: true
+ NumberAnimation {
+ property: "textRightMargin"
+ duration: 50
+ }
+ FadeAnimation {
+ target: passwordVisibilityButton
+ }
+ }
+
+ MouseArea {
+ id: passwordVisibilityButton
+
+ parent: field // ensure the field is visible, avoid auto-parenting to TextBase contentItem
+ x: field.width - width - field.textMargin
+ width: Math.max(textAbc.implicitWidth, textDots.implicitWidth) + field._buttonLeftMargin/2
+ height: field.height - Theme.paddingLarge
+ opacity: 0
+ enabled: false
+
+ onClicked: {
+ field._usePasswordEchoMode = !field._usePasswordEchoMode
+ }
+
+ Text {
+ id: textAbc
+
+ anchors {
+ top: parent.top
+ topMargin: field.textTopMargin
+ horizontalCenter: parent.horizontalCenter
+ }
+ visible: field.echoMode == TextInput.Password
+ font.pixelSize: Theme.fontSizeMedium
+ text: "abc"
+ textFormat: Text.PlainText
+ color: parent.pressed && parent.containsMouse ? Theme.highlightColor : Theme.primaryColor
+ }
+
+ Text {
+ id: textDots
+
+ anchors {
+ top: parent.top
+ topMargin: field.textTopMargin
+ horizontalCenter: parent.horizontalCenter
+ }
+ visible: field.echoMode == TextInput.Normal
+ font.pixelSize: Theme.fontSizeMedium
+ text: "\u2022\u2022\u2022"
+ textFormat: Text.PlainText
+ color: parent.pressed && parent.containsMouse ? Theme.highlightColor : Theme.primaryColor
+ }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourShakeAnimation.qml
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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
+
+SequentialAnimation {
+ id: animation
+
+ property var target
+ property real amplitude: Theme.horizontalPageMargin * 4 / 5
+ property real x: 0
+
+ alwaysRunToEnd: true
+
+ NumberAnimation {
+ target: animation.target
+ property: "x"
+ to: animation.x + animation.amplitude
+ duration: 25
+ easing.type: Easing.InOutSine
+ }
+
+ NumberAnimation {
+ target: animation.target
+ property: "x"
+ from: animation.x + animation.amplitude
+ to: animation.x
+ duration: 500
+ easing.type: Easing.OutElastic
+ easing.amplitude: 2
+ easing.period: 0.2
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/qml/HarbourTextFlip.qml
^
|
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+import QtQuick 2.0
+
+Rotation {
+ id: rotation
+
+ property string text
+ property Item target
+ property real duration: 500
+
+ property var animation: SequentialAnimation {
+ alwaysRunToEnd: true
+
+ onRunningChanged: {
+ if (!running && target.text !== rotation.text) {
+ start()
+ }
+ }
+
+ NumberAnimation {
+ easing.type: Easing.InOutSine
+ target: rotation
+ property: "angle"
+ from: 0
+ to: 90
+ duration: rotation.duration/2
+ }
+ ScriptAction { script: target.text = rotation.text; }
+ NumberAnimation {
+ easing.type: Easing.InOutSine
+ target: rotation
+ property: "angle"
+ to: 0
+ duration: rotation.duration/2
+ }
+ }
+
+ origin {
+ x: target.width / 2
+ y: target.height / 2
+ }
+
+ axis {
+ x: 1
+ y: 0
+ z: 0
+ }
+
+ onTextChanged: animation.start()
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourBase32.cpp
^
|
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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"
+
+#define BASE32_BITS_PER_NIBBLE (5)
+#define BASE32_BYTES_PER_CHUNK (5)
+#define BASE32_NIBBLES_PER_CHUNK (8)
+#define BASE32_BITS_PER_CHUNK (BASE32_BITS_PER_NIBBLE*BASE32_NIBBLES_PER_CHUNK)
+#define BASE32_NIBBLE_MASK ((1 << BASE32_BITS_PER_NIBBLE) - 1)
+Q_STATIC_ASSERT(BASE32_BITS_PER_CHUNK == BASE32_BYTES_PER_CHUNK * 8);
+
+// ==========================================================================
+// HarbourBase32::Private
+// ==========================================================================
+
+class HarbourBase32::Private {
+public:
+ static char nibbleToBase32(int nibble, char a);
+ static int base32ToNibble(char a);
+};
+
+inline char HarbourBase32::Private::nibbleToBase32(int nibble, char a)
+{
+ return (nibble < 26) ? (a + nibble) : ('2' + (nibble - 26));
+}
+
+inline int HarbourBase32::Private::base32ToNibble(char c)
+{
+ if (c >= 'a' && c <= 'z') {
+ return c - 'a';
+ } else if (c >= 'A' && c <= 'Z') {
+ return c - 'A';
+ } else if (c >= '2' && c <= '7') {
+ return 26 + (c - '2');
+ } else {
+ return -1;
+ }
+}
+
+// ==========================================================================
+// HarbourBase32
+// ==========================================================================
+
+bool HarbourBase32::isValidBase32(QString aBase32)
+{
+ const int n = aBase32.length();
+ const QChar* chars = aBase32.constData();
+
+ qint64 buf = 0;
+ int i, bits = 0;
+ bool empty = true;
+
+ for (i = 0; i < n; i++) {
+ const QChar c = chars[i];
+
+ if (!c.isSpace()) {
+ const char l = c.toLatin1();
+
+ empty = false;
+ if (l == '=') {
+ i++;
+ break;
+ } else {
+ const int nibble = Private::base32ToNibble(l);
+
+ if (nibble < 0) {
+ HDEBUG("Invalid BASE32 character" << c);
+ return false;
+ }
+ bits += BASE32_BITS_PER_NIBBLE;
+ buf <<= BASE32_BITS_PER_NIBBLE;
+ buf += nibble;
+ if (bits == BASE32_BITS_PER_CHUNK) {
+ bits = 0;
+ buf = 0;
+ }
+ }
+ }
+ }
+
+ // Handle padding per RFC 4648
+ if (bits) {
+ while (i < n) {
+ const QChar c = chars[i++];
+
+ if (!c.isSpace()) {
+ empty = false;
+ if (c != '=') {
+ HDEBUG("Invalid BASE32 string" << aBase32);
+ return false;
+ }
+ }
+ }
+ const int realbits = bits/8*8;
+ const int mask = (1 << (bits - realbits)) - 1;
+ if (buf & mask) {
+ return false;
+ }
+ }
+ return !empty;
+}
+
+QByteArray HarbourBase32::fromBase32(QString aBase32)
+{
+ QByteArray out;
+
+ const int n = aBase32.length();
+ const QChar* chars = aBase32.constData();
+
+ qint64 buf = 0;
+ int i, bits = 0;
+ char bytes[BASE32_BYTES_PER_CHUNK];
+
+ out.reserve((n * 5 + 7)/8);
+
+ for (i = 0; i < n; i++) {
+ const QChar c = chars[i];
+
+ if (!c.isSpace()) {
+ const char l = c.toLatin1();
+
+ if (l == '=') {
+ i++;
+ break;
+ } else {
+ const int nibble = Private::base32ToNibble(l);
+
+ if (nibble < 0) {
+ HDEBUG("Invalid BASE32 character" << c);
+ return QByteArray();
+ } else {
+ bits += BASE32_BITS_PER_NIBBLE;
+ buf <<= BASE32_BITS_PER_NIBBLE;
+ buf += nibble;
+ if (bits == BASE32_BITS_PER_CHUNK) {
+ bits = 0;
+ for (int k = BASE32_BYTES_PER_CHUNK; k > 0; k--) {
+ bytes[k - 1] = (char)buf;
+ buf >>= 8;
+ }
+ out.append(bytes, BASE32_BYTES_PER_CHUNK);
+ }
+ }
+ }
+ }
+ }
+
+ // Handle padding per RFC 4648
+ if (bits) {
+ while (i < n) {
+ const QChar c = chars[i++];
+
+ if (!c.isSpace() && c != '=') {
+ HDEBUG("Invalid BASE32 string" << aBase32);
+ return QByteArray();
+ }
+ }
+ const int realbits = bits/8*8;
+ const int mask = (1 << (bits - realbits)) - 1;
+ if (buf & mask) {
+ HDEBUG("Invalid BASE32 string" << aBase32);
+ return QByteArray();
+ } else {
+ buf >>= (bits - realbits);
+ for (int k = realbits / 8; k > 0; k--) {
+ bytes[k - 1] = (char)buf;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourDisplayBlanking.cpp
^
|
@@ -8,15 +8,15 @@
* 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
@@ -35,6 +35,8 @@
#include "HarbourDebug.h"
#include "HarbourMce.h"
+#include <QQmlEngine>
+
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCallWatcher>
@@ -45,11 +47,12 @@
// ==========================================================================
// HarbourDisplayBlanking::Private
// ==========================================================================
+
class HarbourDisplayBlanking::Private : public HarbourMce {
Q_OBJECT
public:
- static const int REPEAT_INERVAL_SEC = 50;
+ static const int REPEAT_INTERVAL_SEC = 50;
static const QString BLANK_ACTIVE;
static const QString BLANK_INACTIVE;
static QWeakPointer<HarbourDisplayBlanking> sSharedInstance;
@@ -197,7 +200,7 @@
if (iPauseActive) {
if (!iRepeatTimer) {
iRepeatTimer = new QTimer(this);
- iRepeatTimer->setInterval(REPEAT_INERVAL_SEC * 1000);
+ iRepeatTimer->setInterval(REPEAT_INTERVAL_SEC * 1000);
iRepeatTimer->setSingleShot(false);
connect(iRepeatTimer, SIGNAL(timeout()),
SLOT(onRepeatBlankingRequest()));
@@ -247,6 +250,15 @@
HDEBUG("destroyed");
}
+// Callback for qmlRegisterSingletonType<HarbourDisplayBlanking>
+QObject*
+HarbourDisplayBlanking::createSingleton(
+ QQmlEngine* aEngine,
+ QJSEngine* aScript)
+{
+ return new HarbourDisplayBlanking(aEngine);
+}
+
QSharedPointer<HarbourDisplayBlanking>
HarbourDisplayBlanking::sharedInstance()
{
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourImageProvider.cpp
^
|
@@ -2,7 +2,7 @@
* Copyright (C) 2018 Jolla Ltd.
* Copyright (C) 2018 Slava Monich <slava@monich.com>
*
- * You may use this file under the terms of the BSD license as follows:
+ * 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
@@ -11,93 +11,32 @@
* 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
- * 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.
+ * 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 "HarbourImageProvider.h"
+#include "HarbourTheme.h"
#include "HarbourDebug.h"
#include <QImageReader>
#include <QQuickWindow>
-#include <dlfcn.h>
-
-#define SILICA_SO "/usr/lib/libsailfishsilica.so.1"
-#define SILICA_FUNCTIONS(f) \
- f("_ZN6Silica5Theme8instanceEv", /* Silica::Theme* Silica::Theme::instance() */ \
- HarbourImageProvider::Theme*, Instance,()) \
- f("_ZNK6Silica5Theme5styleEv", /* Silica::Style Silica::Theme::style() const */ \
- HarbourImageProvider::Theme::Style, Style,(HarbourImageProvider::Theme*)) \
- f("_ZNK6Silica5Theme12primaryColorEv", /* QColor Silica::Theme::primaryColor() const */ \
- QColor, PrimaryColor,(HarbourImageProvider::Theme*))
-
-// ==========================================================================
-// HarbourImageProvider::Theme
-// ==========================================================================
-
-class HarbourImageProvider::Theme
-{
-public:
- enum Style {
- StyleLight,
- StyleDark
- };
-
- typedef struct _SilicaFunctions {
- #define SILICA_TYPEDEF(sym,ret,name,args) ret (*name) args;
- SILICA_FUNCTIONS(SILICA_TYPEDEF)
- } SilicaFunctions;
-
- static Theme* instance();
- static Style style(Theme* theme);
-
-public:
- static void* gHandle;
- static SilicaFunctions gSilica;
-};
-
-void* HarbourImageProvider::Theme::gHandle = NULL;
-HarbourImageProvider::Theme::SilicaFunctions HarbourImageProvider::Theme::gSilica;
-
-static const char* SilicaSymbols[] = {
-#define SILICA_SYMBOL(sym,ret,name,args) sym,
- SILICA_FUNCTIONS(SILICA_SYMBOL)
-};
-
-#define _N(a) (sizeof(a)/sizeof((a)[0]))
-#define NUM_FUNCTIONS _N(SilicaSymbols)
-Q_STATIC_ASSERT(sizeof(HarbourImageProvider::Theme::SilicaFunctions) == NUM_FUNCTIONS*sizeof(void*));
-
-HarbourImageProvider::Theme*
-HarbourImageProvider::Theme::instance()
-{
- return gSilica.Instance ? gSilica.Instance() : NULL;
-}
-
-HarbourImageProvider::Theme::Style
-HarbourImageProvider::Theme::style(
- Theme* aTheme)
-{
- return (aTheme && gSilica.Style) ? gSilica.Style(aTheme) : StyleDark;
-}
-
// ==========================================================================
// HarbourImageProvider::TextureFactory
// ==========================================================================
@@ -107,7 +46,7 @@
public:
TextureFactory(QString aPath, QSize requestedSize);
- QSGTexture *createTexture(QQuickWindow *window) const Q_DECL_OVERRIDE;
+ QSGTexture* createTexture(QQuickWindow* aWindow) const Q_DECL_OVERRIDE;
QSize textureSize() const Q_DECL_OVERRIDE;
int textureByteCount() const Q_DECL_OVERRIDE;
QImage image() const Q_DECL_OVERRIDE;
@@ -120,6 +59,7 @@
QString iHighlight;
QSize iRequestedSize;
mutable QImage iImage;
+ HarbourTheme iTheme;
};
HarbourImageProvider::TextureFactory::TextureFactory(
@@ -147,14 +87,13 @@
imageReader.setScaledSize(iRequestedSize);
}
if (imageReader.read(&iImage) && !iImage.isNull()) {
- HDEBUG("loaded" << qPrintable(iPath));
if (iHighlight.isEmpty()) {
- // Invert grayscale icon colors on inverted ambience
- Theme* theme = Theme::instance();
- if (Theme::style(theme) == Theme::StyleLight &&
- iImage.isGrayscale() &&
- Theme::gSilica.PrimaryColor) {
- iImage = colorize(iImage, Theme::gSilica.PrimaryColor(theme));
+ // Colorize grayscale to match ambience
+ if (iImage.isGrayscale()) {
+ QColor primaryColor(iTheme.primaryColor());
+ if (primaryColor.isValid()) {
+ iImage = colorize(iImage, primaryColor);
+ }
}
} else {
// Colorization required
@@ -254,16 +193,6 @@
HarbourImageProvider::HarbourImageProvider() :
QQuickImageProvider(QQuickImageProvider::Texture)
{
- if (!Theme::gHandle) {
- Theme::gHandle = dlopen(SILICA_SO, RTLD_LAZY);
- if (Theme::gHandle) {
- void** ptr = (void**)&Theme::gSilica;
- for (uint i = 0; i < NUM_FUNCTIONS; i++) {
- ptr[i] = dlsym(Theme::gHandle, SilicaSymbols[i]);
- HDEBUG(SilicaSymbols[i] << (ptr[i] ? "OK" : "missing"));
- }
- }
- }
}
QQuickTextureFactory*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourOrganizeListModel.cpp
^
|
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourOrganizeListModel.h"
+
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourOrganizeListModel::Private
+// ==========================================================================
+
+class HarbourOrganizeListModel::Private {
+public:
+ Private();
+
+ int mapToSource(int aRow) const;
+ int mapFromSource(int aRow) const;
+
+public:
+ int iDragIndex;
+ int iDragPos;
+ const char* iRowsAboutToBeMovedSlot;
+ const char* iRowsMovedSlot;
+};
+
+HarbourOrganizeListModel::Private::Private() :
+ iDragIndex(-1),
+ iDragPos(-1),
+ iRowsAboutToBeMovedSlot(SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))),
+ iRowsMovedSlot(SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)))
+{
+}
+
+int HarbourOrganizeListModel::Private::mapToSource(int aRow) const
+{
+ if (iDragIndex < iDragPos) {
+ if (aRow < iDragIndex || aRow > iDragPos) {
+ return aRow;
+ } else if (aRow == iDragPos) {
+ return iDragIndex;
+ } else {
+ return aRow + 1;
+ }
+ } else if (iDragPos < iDragIndex) {
+ if (aRow < iDragPos || aRow > iDragIndex) {
+ return aRow;
+ } else if (aRow == iDragPos) {
+ return iDragIndex;
+ } else {
+ return aRow - 1;
+ }
+ }
+ return aRow;
+}
+
+int HarbourOrganizeListModel::Private::mapFromSource(int aRow) const
+{
+ if (iDragIndex < iDragPos) {
+ if (aRow < iDragIndex || aRow > iDragPos) {
+ return aRow;
+ } else if (aRow == iDragIndex) {
+ return iDragPos;
+ } else {
+ return aRow - 1;
+ }
+ } else if (iDragPos < iDragIndex) {
+ if (aRow < iDragPos || aRow > iDragIndex) {
+ return aRow;
+ } else if (aRow == iDragIndex) {
+ return iDragPos;
+ } else {
+ return aRow + 1;
+ }
+ }
+ return aRow;
+}
+
+// ==========================================================================
+// HarbourOrganizeListModel
+// ==========================================================================
+
+#define SUPER QSortFilterProxyModel
+
+HarbourOrganizeListModel::HarbourOrganizeListModel(QObject* aParent) :
+ SUPER(aParent),
+ iPrivate(new Private)
+{
+}
+
+HarbourOrganizeListModel::~HarbourOrganizeListModel()
+{
+ delete iPrivate;
+}
+
+void HarbourOrganizeListModel::setSourceModelObject(QObject* aModel)
+{
+ setSourceModel(qobject_cast<QAbstractItemModel*>(aModel));
+}
+
+int HarbourOrganizeListModel::dragIndex() const
+{
+ return iPrivate->iDragIndex;
+}
+
+int HarbourOrganizeListModel::dragPos() const
+{
+ return iPrivate->iDragPos;
+}
+
+QModelIndex HarbourOrganizeListModel::mapToSource(const QModelIndex& aIndex) const
+{
+ QAbstractItemModel* source = sourceModel();
+ if (source) {
+ return source->index(iPrivate->mapToSource(aIndex.row()), aIndex.column());
+ }
+ return aIndex;
+}
+
+QModelIndex HarbourOrganizeListModel::mapFromSource(const QModelIndex& aIndex) const
+{
+ return index(iPrivate->mapFromSource(aIndex.row()), aIndex.column());
+}
+
+void HarbourOrganizeListModel::setDragIndex(int aIndex)
+{
+ HDEBUG(aIndex);
+ if (aIndex < 0) {
+ if (iPrivate->iDragIndex >= 0) {
+ // Drag is finished
+ if (iPrivate->iDragPos != iPrivate->iDragIndex) {
+ const int dragIndex = iPrivate->iDragIndex;
+ const int dragPos = iPrivate->iDragPos;
+ iPrivate->iDragPos = iPrivate->iDragIndex = -1;
+ QAbstractItemModel* source = sourceModel();
+ if (source) {
+ //
+ // Now, this is getting a bit hackish.
+ //
+ // We don't need QSortFilterProxyModel to react to
+ // rowsAboutToBeMoved and rowsMoved signals emitted
+ // by the source model when we invoke moveRow() because
+ // that would result in layoutChanged signal which
+ // would reset the view (its current position etc).
+ // That's totally unnecessary because all the rows
+ // are already in the right place as long as the view
+ // is concerned.
+ //
+ // It looks a bit fragile since these slots are
+ // internal and can change at any point of time.
+ // Well, in the worst case we would get the view
+ // reset.
+ //
+ QObject::disconnect(source,
+ SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsAboutToBeMovedSlot);
+ QObject::disconnect(source,
+ SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsMovedSlot);
+
+ // Actually move the row
+ source->moveRow(QModelIndex(), dragIndex, QModelIndex(), dragPos);
+
+ // And (hopefully) reconnect the handlers.
+ QObject::connect(source,
+ SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsAboutToBeMovedSlot);
+ QObject::connect(source,
+ SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsMovedSlot);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourQrCodeGenerator.cpp
^
|
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourQrCodeGenerator.h"
+
+#include "HarbourBase32.h"
+#include "HarbourTask.h"
+#include "HarbourDebug.h"
+
+#include <QThreadPool>
+
+#include "qrencode.h"
+
+// ==========================================================================
+// HarbourQrCodeGenerator::Task
+// ==========================================================================
+
+class HarbourQrCodeGenerator::Task : public HarbourTask {
+ Q_OBJECT
+public:
+ Task(QThreadPool* aPool, QString aText);
+ void performTask() Q_DECL_OVERRIDE;
+public:
+ QString iText;
+ QString iCode;
+};
+
+HarbourQrCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+ HarbourTask(aPool),
+ iText(aText)
+{
+}
+
+void HarbourQrCodeGenerator::Task::performTask()
+{
+ QByteArray bytes(generate(iText));
+ if (!bytes.isEmpty()) {
+ iCode = HarbourBase32::toBase32(bytes);
+ }
+}
+
+// ==========================================================================
+// HarbourQrCodeGenerator::Private
+// ==========================================================================
+
+class HarbourQrCodeGenerator::Private : public QObject {
+ Q_OBJECT
+
+public:
+ Private(HarbourQrCodeGenerator* aParent);
+ ~Private();
+
+ HarbourQrCodeGenerator* parentObject() const;
+ void setText(QString aValue);
+
+public Q_SLOTS:
+ void onTaskDone();
+
+public:
+ QThreadPool* iThreadPool;
+ Task* iTask;
+ QString iText;
+ QString iCode;
+};
+
+HarbourQrCodeGenerator::Private::Private(HarbourQrCodeGenerator* aParent) :
+ QObject(aParent),
+ iThreadPool(new QThreadPool(this)),
+ iTask(Q_NULLPTR)
+{
+ // Serialize the tasks:
+ iThreadPool->setMaxThreadCount(1);
+}
+
+HarbourQrCodeGenerator::Private::~Private()
+{
+ iThreadPool->waitForDone();
+}
+
+inline HarbourQrCodeGenerator* HarbourQrCodeGenerator::Private::parentObject() const
+{
+ return qobject_cast<HarbourQrCodeGenerator*>(parent());
+}
+
+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();
+ }
+ }
+}
+
+void HarbourQrCodeGenerator::Private::onTaskDone()
+{
+ if (sender() == iTask) {
+ HarbourQrCodeGenerator* obj = parentObject();
+ const bool qrCodeChanged = (iCode != iTask->iCode);
+ iCode = iTask->iCode;
+ iTask->release();
+ iTask = NULL;
+ if (qrCodeChanged) {
+ Q_EMIT obj->codeChanged();
+ }
+ Q_EMIT obj->runningChanged();
+ }
+}
+
+// ==========================================================================
+// HarbourQrCodeGenerator
+// ==========================================================================
+
+HarbourQrCodeGenerator::HarbourQrCodeGenerator(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
+QObject* HarbourQrCodeGenerator::createSingleton(QQmlEngine* aEngine, QJSEngine*)
+{
+ return new HarbourQrCodeGenerator(aEngine);
+}
+
+QString HarbourQrCodeGenerator::text() const
+{
+ return iPrivate->iText;
+}
+
+void HarbourQrCodeGenerator::setText(QString aValue)
+{
+ iPrivate->setText(aValue);
+}
+
+QString HarbourQrCodeGenerator::code() const
+{
+ return iPrivate->iCode;
+}
+
+bool HarbourQrCodeGenerator::running() const
+{
+ return iPrivate->iTask != Q_NULLPTR;
+}
+
+QByteArray HarbourQrCodeGenerator::generate(QString aText)
+{
+ QByteArray in(aText.toUtf8()), out;
+ QRcode* code = QRcode_encodeString(in.constData(), 0, QR_ECLEVEL_M, QR_MODE_8, true);
+ if (code) {
+ const int bytesPerRow = (code->width + 7) / 8;
+ if (bytesPerRow > 0) {
+ out.reserve(bytesPerRow * code->width);
+ for (int y = 0; y < code->width; y++) {
+ const unsigned char* row = code->data + (code->width * y);
+ char c = (row[0] & 1);
+ int x = 1;
+ for (; x < code->width; x++) {
+ if (!(x % 8)) {
+ out.append(&c, 1);
+ c = row[x] & 1;
+ } else {
+ c = (c << 1) | (row[x] & 1);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourQrCodeImageProvider.cpp
^
|
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourQrCodeImageProvider.h"
+
+#include "HarbourBase32.h"
+#include "HarbourDebug.h"
+
+#include <QVector>
+#include <QColor>
+#include <QRgb>
+
+const QColor HarbourQrCodeImageProvider::DEFAULT_COLOR(Qt::black);
+const QColor HarbourQrCodeImageProvider::DEFAULT_BACKGROUND(Qt::transparent);
+
+QImage HarbourQrCodeImageProvider::createImage(QByteArray aBits, QColor aColor, QColor aBackground)
+{
+ if (aBits.size() > 0) {
+ // Bits are packed, rows are rounded at byte boundary
+ int rows, rowSize;
+ for (rows = 2; ((rowSize = (rows + 7)/8) * rows) < aBits.size(); rows++);
+ if ((rows * rowSize) == aBits.size()) {
+ HDEBUG(rows << "x" << rows);
+ QImage img(rows, rows, QImage::Format_Mono);
+ QVector<QRgb> colors;
+ QColor background(aBackground.isValid() ? aBackground : DEFAULT_BACKGROUND);
+ QColor color(aColor.isValid() ? aColor : DEFAULT_COLOR);
+ colors.append(background.rgba());
+ colors.append(color.rgba());
+ img.setColorTable(colors);
+ for (int y = 0; y < rows; y++) {
+ memcpy(img.scanLine(y), aBits.constData() + y * rowSize, rowSize);
+ }
+ return img;
+ }
+ }
+ return QImage();
+}
+
+QImage HarbourQrCodeImageProvider::requestImage(const QString& aId, QSize* aSize, const QSize&)
+{
+ // Default background and foreground
+ QColor background(DEFAULT_BACKGROUND), color(DEFAULT_COLOR);
+
+ // Parse parameters
+ QString base32;
+ const int sep = aId.indexOf('?');
+ if (sep < 0) {
+ base32 = aId;
+ } else {
+ base32 = aId.left(sep);
+ const QStringList params(aId.mid(sep + 1).split('&', QString::SkipEmptyParts));
+ const int n = params.count();
+ for (int i = 0; i < n; i++) {
+ const QString param(params.at(i));
+ const int eq = param.indexOf('=');
+ if (eq > 0) {
+ static const QString BACKGROUND("background");
+ static const QString COLOR("color");
+ const QString name(param.left(eq).trimmed());
+ const QString value(param.mid(eq + 1).trimmed());
+ if (name == COLOR) {
+ const QColor colorValue(value);
+ if (colorValue.isValid()) {
+ color = colorValue;
+ } else {
+ HDEBUG("Invalid" << qPrintable(name) << value);
+ }
+ } else if (name == BACKGROUND) {
+ const QColor colorValue(value);
+ if (colorValue.isValid()) {
+ background = colorValue;
+ } else {
+ HDEBUG("Invalid" << qPrintable(name) << value);
+ }
+ } else {
+ HDEBUG("Invalid parameter name" << name);
+ }
+ } else {
+ HDEBUG("Invalid parameter" << param);
+ }
+ }
+ }
+
+ // Decode BASE32
+ const QByteArray bits(HarbourBase32::fromBase32(base32.toLocal8Bit()));
+ HDEBUG(base32 << "=>" << bits.size() << "bytes");
+
+ // Convert to image
+ QImage img(createImage(bits, color, background));
+ if (!img.isNull() && aSize) {
+ *aSize = img.size();
+ }
+
+ return img;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourSingleImageProvider.cpp
^
|
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourSingleImageProvider.h"
+
+#include "HarbourDebug.h"
+
+#include <QQuickImageProvider>
+#include <QQmlEngine>
+#include <QQmlContext>
+
+// ==========================================================================
+// HarbourSingleImageProvider::ImageProvider
+// ==========================================================================
+
+class HarbourSingleImageProvider::ImageProvider : public QQuickImageProvider {
+public:
+ static const QString IMAGE_NAME;
+
+ ImageProvider(QImage aImage);
+
+ QImage requestImage(const QString& aId, QSize* aSize,
+ const QSize& aRequested) Q_DECL_OVERRIDE;
+
+private:
+ QImage iImage;
+};
+
+const QString HarbourSingleImageProvider::ImageProvider::IMAGE_NAME("image");
+
+HarbourSingleImageProvider::ImageProvider::ImageProvider(QImage aImage) :
+ QQuickImageProvider(Image),
+ iImage(aImage)
+{
+}
+
+QImage HarbourSingleImageProvider::ImageProvider::requestImage(const QString& aId,
+ QSize* aSize, const QSize& aRequested)
+{
+ HDEBUG(aId);
+ if (aSize) {
+ *aSize = iImage.size();
+ }
+ return iImage;
+}
+
+// ==========================================================================
+// HarbourSingleImageProvider::Private
+// ==========================================================================
+
+class HarbourSingleImageProvider::Private : public QObject {
+ Q_OBJECT
+
+public:
+ Private(HarbourSingleImageProvider* aParent);
+ ~Private();
+
+ bool setEngine(QQmlEngine* aEngine);
+ bool setImage(QImage aImage);
+ void registerProvider();
+
+public Q_SLOTS:
+ void onEngineDied();
+
+public:
+ QImage iImage;
+ QString iId;
+ QString iSourceUri;
+ QQmlEngine* iEngine;
+};
+
+HarbourSingleImageProvider::Private::Private(HarbourSingleImageProvider* aParent) :
+ QObject(aParent),
+ iEngine(Q_NULLPTR)
+{
+}
+
+HarbourSingleImageProvider::Private::~Private()
+{
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ }
+}
+
+void HarbourSingleImageProvider::Private::registerProvider()
+{
+ QQmlImageProviderBase* provider = new ImageProvider(iImage);
+ iId = QString().sprintf("HarbourSingleImageProvider%p", provider);
+ iSourceUri = QString("image://%1/%2").arg(iId, ImageProvider::IMAGE_NAME);
+ HDEBUG("registering provider" << iId);
+ iEngine->addImageProvider(iId, provider);
+}
+
+bool HarbourSingleImageProvider::Private::setEngine(QQmlEngine* aEngine)
+{
+ if (iEngine) {
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ iId = QString();
+ }
+ iEngine->disconnect(this);
+ }
+ iEngine = aEngine;
+ if (iEngine) {
+ connect(iEngine, SIGNAL(destroyed(QObject*)), SLOT(onEngineDied()));
+ if (!iImage.isNull()) {
+ registerProvider();
+ return true;
+ }
+ }
+ return false;
+}
+
+bool HarbourSingleImageProvider::Private::setImage(QImage aImage)
+{
+ HDEBUG(aImage);
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ }
+ iImage = aImage;
+ if (iEngine && !iImage.isNull()) {
+ registerProvider();
+ return true;
+ }
+ return false;
+}
+
+void HarbourSingleImageProvider::Private::onEngineDied()
+{
+ HDEBUG("engine died");
+ iEngine = Q_NULLPTR;
+ iId = QString();
+}
+
+// ==========================================================================
+// HarbourSingleImageProvider
+// ==========================================================================
+
+HarbourSingleImageProvider::HarbourSingleImageProvider(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+void HarbourSingleImageProvider::classBegin()
+{
+}
+
+void HarbourSingleImageProvider::componentComplete()
+{
+ QQmlContext* context = QQmlEngine::contextForObject(this);
+ HDEBUG(context);
+ if (context) {
+ QQmlEngine* engine = context->engine();
+ HDEBUG(engine);
+ if (iPrivate->setEngine(engine)) {
+ Q_EMIT sourceChanged();
+ }
+ }
+}
+
+QImage HarbourSingleImageProvider::image() const
+{
+ return iPrivate->iImage;
+}
+
+void HarbourSingleImageProvider::setImage(QImage aImage)
+{
+ HDEBUG(aImage);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourSystemState.cpp
^
|
@@ -8,15 +8,15 @@
* 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
@@ -35,6 +35,8 @@
#include "HarbourDebug.h"
#include "HarbourMce.h"
+#include <QQmlEngine>
+
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCall>
@@ -190,6 +192,15 @@
HDEBUG("destroyed");
}
+// Callback for qmlRegisterSingletonType<HarbourSystemState>
+QObject*
+HarbourSystemState::createSingleton(
+ QQmlEngine* aEngine,
+ QJSEngine* aScript)
+{
+ return new HarbourSystemState(aEngine);
+}
+
QSharedPointer<HarbourSystemState>
HarbourSystemState::sharedInstance()
{
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourTask.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2019 Jolla Ltd.
+ * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -14,9 +14,9 @@
* 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
@@ -47,18 +47,22 @@
public:
QThreadPool* iPool;
- bool iAboutToQuit;
+ QObject* iTarget;
+ bool iStarted; // These two flags are set by the worker thread
+ bool iFinished;
+ bool iAboutToQuit; // All other flags are set by the main thread
bool iSubmitted;
- bool iStarted;
bool iReleased;
bool iDone;
};
HarbourTask::Private::Private(QThreadPool* aPool) :
iPool(aPool),
+ iTarget(NULL),
+ iStarted(false),
+ iFinished(false),
iAboutToQuit(false),
iSubmitted(false),
- iStarted(false),
iReleased(false),
iDone(false)
{
@@ -82,7 +86,7 @@
HarbourTask::~HarbourTask()
{
HASSERT(iPrivate->iReleased);
- if (iPrivate->iSubmitted) wait();
+ HASSERT(!iPrivate->iSubmitted || iPrivate->iFinished);
delete iPrivate;
}
@@ -108,19 +112,26 @@
void HarbourTask::submit(QObject* aTarget, const char* aSlot)
{
+ HASSERT(!iPrivate->iTarget);
+ iPrivate->iTarget = aTarget;
+ connect(aTarget, SIGNAL(destroyed(QObject*)), SLOT(onTargetDestroyed(QObject*)));
aTarget->connect(this, SIGNAL(done()), aSlot);
submit();
}
void HarbourTask::release(QObject* aHandler)
{
+ aHandler->disconnect(this);
disconnect(aHandler);
released();
}
void HarbourTask::release()
{
- disconnect();
+ if (iPrivate->iTarget) {
+ iPrivate->iTarget->disconnect(this);
+ disconnect(iPrivate->iTarget);
+ }
released();
}
@@ -136,7 +147,10 @@
{
HASSERT(!iPrivate->iStarted);
iPrivate->iStarted = true;
- performTask();
+ if (!isCanceled()) {
+ performTask();
+ }
+ iPrivate->iFinished = true;
Q_EMIT runFinished();
}
@@ -157,3 +171,12 @@
HDEBUG("OK");
iPrivate->iAboutToQuit = true;
}
+
+void HarbourTask::onTargetDestroyed(QObject* aObject)
+{
+ HDEBUG(aObject);
+ HASSERT(iPrivate->iTarget == aObject);
+ if (iPrivate->iTarget == aObject) {
+ iPrivate->iTarget = NULL;
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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 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 "HarbourTheme.h"
+#include "HarbourDebug.h"
+
+#include <QQmlEngine>
+
+#include <dlfcn.h>
+
+#define SILICA_SO "/usr/lib/libsailfishsilica.so.1"
+#define SILICA_FUNCTIONS(f) \
+ f("_ZN6Silica5Theme8instanceEv", /* Silica::Theme* Silica::Theme::instance() */ \
+ QObject*, instance,()) \
+ f("_ZNK6Silica5Theme5styleEv", /* Silica::Style Silica::Theme::style() const */ \
+ HarbourTheme::Private::Style, style,(QObject*)) \
+ f("_ZNK6Silica5Theme11colorSchemeEv", /* Silica::ColorScheme Silica::Theme::colorScheme() const */ \
+ HarbourTheme::ColorScheme, colorScheme,(QObject*)) \
+ f("_ZNK6Silica5Theme12primaryColorEv", /* QColor Silica::Theme::primaryColor() const */ \
+ QColor, primaryColor,(QObject*))
+
+// ==========================================================================
+// HarbourTheme::Private
+// ==========================================================================
+
+class HarbourTheme::Private
+{
+public:
+ enum Style {
+ StyleLight,
+ StyleDark
+ };
+
+ typedef struct _SilicaFunctions {
+ #define SILICA_TYPEDEF(sym,ret,name,args) ret (*name) args;
+ SILICA_FUNCTIONS(SILICA_TYPEDEF)
+ } SilicaFunctions;
+
+ static void* gHandle;
+ static SilicaFunctions gSilica;
+
+public:
+ static QObject* instance();
+ static ColorScheme colorScheme();
+ static QColor primaryColor();
+};
+
+void* HarbourTheme::Private::gHandle;
+HarbourTheme::Private::SilicaFunctions HarbourTheme::Private::gSilica;
+
+static const char* SilicaSymbols[] = {
+#define SILICA_SYMBOL(sym,ret,name,args) sym,
+ SILICA_FUNCTIONS(SILICA_SYMBOL)
+};
+
+#define _N(a) (sizeof(a)/sizeof((a)[0]))
+#define NUM_FUNCTIONS _N(SilicaSymbols)
+Q_STATIC_ASSERT(sizeof(HarbourTheme::Private::SilicaFunctions) == NUM_FUNCTIONS*sizeof(void*));
+
+QObject* HarbourTheme::Private::instance()
+{
+ return gSilica.instance ? gSilica.instance() : NULL;
+}
+
+HarbourTheme::ColorScheme HarbourTheme::Private::colorScheme()
+{
+ QObject* silica = instance();
+ if (silica) {
+ if (gSilica.colorScheme) {
+ return gSilica.colorScheme(silica);
+ } else if (gSilica.style) {
+ gSilica.style(silica);
+ }
+ }
+ return LightOnDark;
+}
+
+QColor HarbourTheme::Private::primaryColor()
+{
+ QObject* silica = instance();
+ return (silica && gSilica.primaryColor) ? gSilica.primaryColor(silica) : QColor();
+}
+
+// ==========================================================================
+// HarbourTheme
+// ==========================================================================
+
+HarbourTheme::HarbourTheme(QObject* aParent) : QObject(aParent)
+{
+ if (!Private::gHandle) {
+ Private::gHandle = dlopen(SILICA_SO, RTLD_LAZY);
+ if (Private::gHandle) {
+ void** ptr = (void**)&Private::gSilica;
+ for (uint i = 0; i < NUM_FUNCTIONS; i++) {
+ ptr[i] = dlsym(Private::gHandle, SilicaSymbols[i]);
+ HDEBUG(SilicaSymbols[i] << (ptr[i] ? "OK" : "missing"));
+ }
+ }
+ }
+ QObject* silica = Private::instance();
+ if (silica) {
+ if (Private::gSilica.colorScheme) {
+ // Colors update is delayed, queue this signal
+ QObject::connect(silica,
+ SIGNAL(colorSchemeChanged()),
+ SIGNAL(colorSchemeChanged()),
+ Qt::QueuedConnection);
+ }
+ if (Private::gSilica.primaryColor) {
+ QObject::connect(silica,
+ SIGNAL(primaryColorChanged()),
+ SIGNAL(primaryColorChanged()));
+ }
+ }
+}
+
+HarbourTheme::~HarbourTheme()
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourTheme>
+QObject* HarbourTheme::createSingleton(QQmlEngine* aEngine, QJSEngine* aScript)
+{
+ return new HarbourTheme(aEngine);
+}
+
+QColor HarbourTheme::primaryColor() const
+{
+ return Private::primaryColor();
+}
+
+HarbourTheme::ColorScheme HarbourTheme::colorScheme() const
+{
+ return Private::colorScheme();
+}
+
+bool HarbourTheme::lightOnDark() const
+{
+ return Private::colorScheme() == LightOnDark;
+}
+
+bool HarbourTheme::darkOnLight() const
+{
+ return Private::colorScheme() == DarkOnLight;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/harbour-lib/src/HarbourTransferMethodsModel.cpp
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2019 Jolla Ltd.
+ * Copyright (C) 2016-2019 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,29 +11,31 @@
* 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
+ * 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 "HarbourTransferMethodsModel.h"
#include "HarbourDebug.h"
#include <QTranslator>
+#include <QQmlEngine>
// ==========================================================================
// HarbourTransferMethodsModel::TransferEngine
@@ -87,6 +89,13 @@
delete iTransferEngine;
}
+// Callback for qmlRegisterSingletonType<HarbourTransferMethodsModel>
+QObject*
+HarbourTransferMethodsModel::createSingleton(QQmlEngine* aEngine, QJSEngine* aScript)
+{
+ return new HarbourTransferMethodsModel(aEngine);
+}
+
bool HarbourTransferMethodsModel::loadTranslations(QTranslator* aTranslator, QLocale aLocale)
{
if (aTranslator->load(aLocale, "sailfish_transferengine_plugins", "-",
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess
^
|
+(directory)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/.gitignore
^
|
@@ -0,0 +1,21 @@
+*~
+test/coverage/full.gcov
+test/coverage/libdbusaccess.gcov
+test/coverage/results
+debian/files
+debian/libdbusaccess-dev.debhelper.log
+debian/libdbusaccess-dev.substvars
+debian/libdbusaccess-dev
+debian/libdbusaccess.debhelper.log
+debian/libdbusaccess.postinst.debhelper
+debian/libdbusaccess.postrm.debhelper
+debian/libdbusaccess.substvars
+debian/libdbusaccess
+debian/dbusaccess-tools.debhelper.log
+debian/dbusaccess-tools.substvars
+debian/dbusaccess-tools
+debian/tmp
+documentation.list
+installroot
+build
+RPMS
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/LICENSE
^
|
@@ -0,0 +1,28 @@
+Copyright (C) 2017-2019 Jolla Ltd.
+
+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 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.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/Makefile
^
|
@@ -0,0 +1,260 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release test
+
+#
+# Required packages
+#
+
+PKGS = libglibutil gio-2.0 glib-2.0
+
+#
+# Default target
+#
+
+all: debug release pkgconfig
+
+#
+# Library version
+#
+
+VERSION_MAJOR = 1
+VERSION_MINOR = 0
+VERSION_RELEASE = 8
+
+# Version for pkg-config
+PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
+
+#
+# Library name
+#
+
+NAME = dbusaccess
+LIB_NAME = lib$(NAME)
+LIB_DEV_SYMLINK = $(LIB_NAME).so
+LIB_SYMLINK1 = $(LIB_DEV_SYMLINK).$(VERSION_MAJOR)
+LIB_SYMLINK2 = $(LIB_SYMLINK1).$(VERSION_MINOR)
+LIB_SONAME = $(LIB_SYMLINK1)
+LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_RELEASE)
+
+#
+# Sources
+#
+
+SRC = \
+ dbusaccess_cred.c \
+ dbusaccess_peer.c \
+ dbusaccess_parser.c \
+ dbusaccess_policy.c \
+ dbusaccess_self.c \
+ dbusaccess_system.c
+GEN_SRC = \
+ dbusaccess_policy1.tab.c \
+ dbusaccess_policy1.yy.c
+
+#
+# Directories
+#
+
+SRC_DIR = src
+INCLUDE_DIR = include
+BUILD_DIR = build
+GEN_DIR = $(BUILD_DIR)
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Code coverage
+#
+
+ifndef GCOV
+GCOV = 0
+endif
+
+ifneq ($(GCOV),0)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+endif
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(INCLUDE_DIR) -I$(GEN_DIR) -I$(SRC_DIR)
+BASE_FLAGS = -fPIC
+FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
+ -MMD -MP $(shell pkg-config --cflags $(PKGS))
+FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) \
+ $(shell pkg-config --libs $(PKGS))
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+endif
+
+DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+PKGCONFIG = $(BUILD_DIR)/$(LIB_NAME).pc
+DEBUG_OBJS = \
+ $(GEN_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = \
+ $(GEN_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
+ $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+GEN_FILES = $(GEN_SRC:%=$(GEN_DIR)/%)
+.PRECIOUS: $(GEN_FILES)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(GEN_FILES): | $(GEN_DIR)
+$(DEBUG_OBJS) $(DEBUG_LIB): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS) $(RELEASE_LIB): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
+RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
+DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
+RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
+
+debug: $(DEBUG_LIB) $(DEBUG_LINK)
+
+release: $(RELEASE_LIB) $(RELEASE_LINK)
+
+pkgconfig: $(PKGCONFIG)
+
+print_debug_lib:
+ @echo $(DEBUG_LIB)
+
+print_release_lib:
+ @echo $(RELEASE_LIB)
+
+print_debug_link:
+ @echo $(DEBUG_LINK)
+
+print_release_link:
+ @echo $(RELEASE_LINK)
+
+print_debug_path:
+ @echo $(DEBUG_BUILD_DIR)
+
+print_release_path:
+ @echo $(RELEASE_BUILD_DIR)
+
+clean:
+ make -C test clean
+ make -C tools/dbus-creds clean
+ rm -fr test/coverage/results test/coverage/*.gcov
+ rm -f *~ $(SRC_DIR)/*~ $(INCLUDE_DIR)/*~
+ rm -fr $(BUILD_DIR) RPMS installroot
+ rm -fr debian/tmp debian/dbusaccess-tools
+ rm -fr debian/libdbusaccess debian/libdbusaccess-dev
+ rm -f documentation.list debian/files debian/*.substvars
+ rm -f debian/*.debhelper.log debian/*.debhelper debian/*~
+
+test:
+ make -C test test
+
+$(GEN_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(GEN_DIR)/%.tab.c : $(SRC_DIR)/%.y
+ bison -d -o $@ $<
+
+$(GEN_DIR)/%.yy.c : $(SRC_DIR)/%.l
+ flex -o $@ $<
+
+$(DEBUG_BUILD_DIR)/%.o : $(GEN_DIR)/%.c
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/README
^
|
@@ -0,0 +1,18 @@
+Provides functions for implementing finer and dynamic D-Bus access
+control that supplements the built-in D-Bus security mechanisms.
+The functions fall into these two groups:
+
+* Checking the peer's credentials
+* Parsing and applying access control policies
+
+The peer's credentials are queried with GetConnectionUnixProcessID
+and the results are cached for certain period of time or until the
+peer disappears.
+
+It allows to get around the following issues and limitations of the
+built-in D-Bus security policies:
+
+* They ignore the effective group id of the caller
+* They don't analyze the arguments of the call
+* They don't allow to select actions based on credentials
+* They are static
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/changelog
^
|
@@ -0,0 +1,54 @@
+libdbusaccess (1.0.8) unstable; urgency=low
+
+ * Tolerate non-existent users and groups
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 03 Apr 2019 19:15:26 +0300
+
+libdbusaccess (1.0.7) unstable; urgency=low
+
+ * Clean better after debian build
+ * Silence annoying error message
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 15 Mar 2019 16:53:56 +0200
+
+libdbusaccess (1.0.6) unstable; urgency=low
+
+ * Packaged dbus-creds tool
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 11 Oct 2017 11:48:05 +0300
+
+libdbusaccess (1.0.5) unstable; urgency=low
+
+ * Fixed gid_t build issue
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 16 Aug 2017 21:18:06 +0300
+
+libdbusaccess (1.0.4) unstable; urgency=low
+
+ * Added DASelf object
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 02 Apr 2017 18:04:37 +0300
+
+libdbusaccess (1.0.3) unstable; urgency=low
+
+ * Made dbusaccess_system.h public
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 29 Mar 2017 12:45:32 +0300
+
+libdbusaccess (1.0.2) unstable; urgency=low
+
+ * Added da_policy_equal() function
+
+ -- Slava Monich <slava.monich@jolla.com> Tue, 28 Mar 2017 12:13:16 +0300
+
+libdbusaccess (1.0.1) unstable; urgency=low
+
+ * Support policy check against NULL credentials
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 04 Mar 2017 13:14:05 +0200
+
+libdbusaccess (1.0.0) unstable; urgency=low
+
+ * Initial release
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 03 Mar 2017 11:57:39 +0200
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/compat
^
|
@@ -0,0 +1 @@
+5
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/control
^
|
@@ -0,0 +1,24 @@
+Source: libdbusaccess
+Section: libs
+Priority: optional
+Maintainer: Slava Monich <slava.monich@jolla.com>
+Build-Depends: debhelper (>= 7), libglib2.0-dev (>= 2.0), libglibutil-dev
+Standards-Version: 3.8.4
+
+Package: libdbusaccess
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: D-Bus access control library
+
+Package: libdbusaccess-dev
+Section: libdevel
+Architecture: any
+Depends: libdbusaccess (= ${binary:Version}), ${misc:Depends}
+Description: Development files for libdbusaccess
+
+Package: dbusaccess-tools
+Section: utils
+Architecture: any
+Depends: libdbusaccess, ${shlibs:Depends}, ${misc:Depends}
+Description: D-Bus access tools
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/copyright
^
|
@@ -0,0 +1,28 @@
+Copyright (C) 2017 Jolla Ltd.
+
+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 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.
+
+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.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/dbusaccess-tools.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/bin/* usr/bin
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/libdbusaccess-dev.install
^
|
@@ -0,0 +1,3 @@
+debian/tmp/usr/lib/libdbusaccess.so usr/lib
+include/*.h usr/include/dbusaccess
+build/libdbusaccess.pc usr/lib/pkgconfig
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/libdbusaccess.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libdbusaccess.so.* usr/lib
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/rules
^
|
@@ -0,0 +1,22 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+DBUS_CREDS_DIR=tools/dbus-creds
+
+override_dh_auto_clean:
+ dh_auto_clean
+ dh_auto_clean -- -C $(DBUS_CREDS_DIR)
+
+override_dh_auto_build:
+ dh_auto_build
+ dh_auto_build -- -C $(DBUS_CREDS_DIR)
+
+override_dh_auto_install:
+ dh_auto_install -- install-dev
+ dh_auto_install -- -C $(DBUS_CREDS_DIR)
+
+%:
+ dh $@
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/source/format
^
|
@@ -0,0 +1 @@
+1.0
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/debian/source/options
^
|
@@ -0,0 +1 @@
+tar-ignore = ".git"
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/include/dbusaccess_peer.h
^
|
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_PEER_H
+#define DBUSACCESS_PEER_H
+
+#include "dbusaccess_types.h"
+
+G_BEGIN_DECLS
+
+struct da_peer {
+ DA_BUS bus;
+ const char* name;
+ pid_t pid;
+ DACred cred;
+};
+
+/*
+ * You don't need to unref the DAPeer returned by da_peer_get. The reference
+ * is stored internally by the library for certain period of time. It means
+ * however that the object can go away at any time. If you need to keep the
+ * pointer to this object, then you need to da_peer_ref and then da_peer_unref
+ * it when you no longer need it.
+ */
+
+DAPeer*
+da_peer_get(
+ DA_BUS bus,
+ const char* name);
+
+DAPeer*
+da_peer_ref(
+ DAPeer* peer);
+
+void
+da_peer_unref(
+ DAPeer* peer);
+
+void
+da_peer_flush(
+ DA_BUS bus,
+ const char* name);
+
+G_END_DECLS
+
+#endif /* DBUSACCESS_PEER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/include/dbusaccess_policy.h
^
|
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_POLICY_H
+#define DBUSACCESS_POLICY_H
+
+#include "dbusaccess_types.h"
+
+G_BEGIN_DECLS
+
+/*
+ * The policy grammar is described in the .y file. Here is an example:
+ *
+ * 1;group(privileged)&get(Passphrase)=allow
+ *
+ * It's basically the format version (1) followed by rules separated
+ * by semicolons. Each rule is a logical expression optionally followed
+ * by the access specifier =allow or =deny (default is =allow). The
+ * rules are applied in the order in this they appear in the policy.
+ * The following functions are built into the parser:
+ *
+ * user(uid)
+ * group(gid)
+ * user(uid:gid) is equivalent to (user(uid)&group(gid))
+ *
+ * Three logical operators are supported: ! (not), | (or), & (and) as
+ * well parentheses for complex expressions. If the pattern contains
+ * spaces, it has to be enclosed in quotes, either single or double.
+ */
+
+#define DA_POLICY_VERSION "1"
+
+typedef struct da_action {
+ const char* name; /* Action name defined by the caller */
+ guint id; /* Non-zero unique id for compiled representation */
+ guint args; /* Number of arguments (currently only 0 or 1) */
+} DA_ACTION;
+
+DAPolicy*
+da_policy_new(
+ const char* spec);
+
+DAPolicy*
+da_policy_new_full(
+ const char* spec,
+ const DA_ACTION* actions);
+
+DAPolicy*
+da_policy_ref(
+ DAPolicy* policy);
+
+void
+da_policy_unref(
+ DAPolicy* policy);
+
+gboolean
+da_policy_equal(
+ const DAPolicy* policy1,
+ const DAPolicy* policy2);
+
+DA_ACCESS
+da_policy_check(
+ const DAPolicy* policy,
+ const DACred* cred,
+ guint action,
+ const char* arg,
+ DA_ACCESS def);
+
+G_END_DECLS
+
+#endif /* DBUSACCESS_POLICY_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/include/dbusaccess_self.h
^
|
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_SELF_H
+#define DBUSACCESS_SELF_H
+
+#include "dbusaccess_types.h"
+
+G_BEGIN_DECLS
+
+struct da_self {
+ pid_t pid;
+ DACred cred;
+};
+
+/*
+ * da_self_new_shared returns the reference to the shared instance,
+ * da_self_new always allocates the new one. Shared instance should
+ * only be used if you can assume that process credentials never change.
+ *
+ * You can use da_self_flush to clear the shared instance and force the
+ * next da_self_new_shared call to create a new one.
+ */
+
+DASelf*
+da_self_new(
+ void);
+
+DASelf*
+da_self_new_shared(
+ void);
+
+DASelf*
+da_self_ref(
+ DASelf* self);
+
+void
+da_self_unref(
+ DASelf* self);
+
+void
+da_self_flush(
+ void);
+
+G_END_DECLS
+
+#endif /* DBUSACCESS_SELF_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/include/dbusaccess_system.h
^
|
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_SYSTEM_H
+#define DBUSACCESS_SYSTEM_H
+
+#include "dbusaccess_types.h"
+
+int
+da_system_uid(
+ const char* user);
+
+int
+da_system_gid(
+ const char* group);
+
+#endif /* DBUSACCESS_SYSTEM_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/include/dbusaccess_types.h
^
|
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_TYPES_H
+#define DBUSACCESS_TYPES_H
+
+#include <gutil_types.h>
+#include <sys/types.h>
+
+G_BEGIN_DECLS
+
+#define DBUSACCESS_LOG_MODULE dbusaccess_log
+
+typedef enum da_access {
+ DA_ACCESS_DENY,
+ DA_ACCESS_ALLOW
+} DA_ACCESS;
+
+typedef enum da_bus {
+ DA_BUS_SYSTEM,
+ DA_BUS_SESSION
+} DA_BUS;
+
+typedef struct da_cred {
+ uid_t euid;
+ gid_t egid;
+ const gid_t* groups;
+ guint ngroups;
+ guint64 caps;
+ guint32 flags;
+
+#define DBUSACCESS_CRED_CAPS (0x0001)
+#define DBUSACCESS_CRED_GROUPS (0x0002)
+
+} DACred;
+
+typedef struct da_self DASelf;
+typedef struct da_peer DAPeer;
+typedef struct da_policy /* opaque */ DAPolicy;
+
+extern GLogModule DBUSACCESS_LOG_MODULE;
+
+G_END_DECLS
+
+#endif /* DBUSACCESS_TYPES_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/libdbusaccess.pc.in
^
|
@@ -0,0 +1,10 @@
+name=dbusaccess
+libdir=/usr/lib
+includedir=/usr/include
+
+Name: libdbusaccess
+Description: D-Bus access control library
+Version: [version]
+Requires: gio-2.0 glib-2.0 libglibutil
+Libs: -L${libdir} -l${name}
+Cflags: -I${includedir} -I${includedir}/${name}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/rpm/libdbusaccess.spec
^
|
@@ -0,0 +1,65 @@
+Name: libdbusaccess
+Version: 1.0.8
+Release: 0
+Summary: Access control over D-Bus
+Group: Development/Libraries
+License: BSD
+URL: https://git.merproject.org/mer-core/libdbusaccess
+Source: %{name}-%{version}.tar.bz2
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(libglibutil)
+BuildRequires: bison
+BuildRequires: flex
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Provides library for controlling access over D-Bus
+
+%package -n dbusaccess-tools
+Summary: D-Bus access utilities
+
+%description -n dbusaccess-tools
+Provides dbus-creds tool
+
+%files -n dbusaccess-tools
+%defattr(-,root,root,-)
+%{_bindir}/dbus-creds
+
+%package devel
+Summary: Development library for %{name}
+Requires: %{name} = %{version}
+Requires: pkgconfig
+
+%description devel
+This package contains the development library for %{name}.
+
+%prep
+%setup -q
+
+%build
+make KEEP_SYMBOLS=1 release pkgconfig
+make KEEP_SYMBOLS=1 -C tools/dbus-creds release
+
+%install
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install-dev
+make DESTDIR=%{buildroot} -C tools/dbus-creds install
+
+%check
+make -C test test
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/%{name}.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/%{name}.so
+%{_includedir}/dbusaccess/*.h
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_cred.c
^
|
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_cred_p.h"
+
+/* Process status file parsing */
+
+#define PROC_PARSE_UID (0x0001)
+#define PROC_PARSE_GID (0x0002)
+#define PROC_PARSE_GROUPS (0x0004)
+#define PROC_PARSE_CAP_EFF (0x0008)
+#define PROC_PARSE_ALL (0x000f)
+#define PROC_PARSE_UID_OK (0x0010)
+#define PROC_PARSE_GID_OK (0x0020)
+
+static
+gboolean
+da_cred_parse_uint32(
+ const char* str,
+ guint32* result)
+{
+ char* end = NULL;
+ guint64 val64 = g_ascii_strtoull(str, &end, 0);
+ /* The input string is guaranteed to be non-empty */
+ if (!end[0]) {
+ /* Check for overflow */
+ guint32 val32 = (guint32)val64;
+ if ((guint64)val32 == val64) {
+ *result = val32;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static
+gboolean
+da_cred_parse_uint64(
+ const char* str,
+ guint64* result)
+{
+ char* end = NULL;
+ guint64 val = g_ascii_strtoull(str, &end, 16);
+ /* The input string is guaranteed to be non-empty */
+ if (!end[0]) {
+ *result = val;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static
+const char*
+da_cred_parse_values(
+ GPtrArray* vals,
+ const char* data,
+ const char* end)
+{
+ const char* ptr = data;
+ const char* eol = data;
+ g_ptr_array_set_size(vals, 0);
+ g_ptr_array_set_free_func(vals, g_free);
+ /* Find the end of line */
+ while (eol < end && *eol != '\n') eol++;
+ /* Skip spaces before the first word */
+ while (ptr < eol && g_ascii_isspace(*ptr)) ptr++;
+ /* Parse values word by word */
+ while (ptr < eol) {
+ const char* word = ptr;
+ while (ptr < eol && !g_ascii_isspace(*ptr)) ptr++;
+ g_ptr_array_add(vals, g_strndup(word, ptr - word));
+ /* Skip spaces after the word */
+ while (ptr < eol && g_ascii_isspace(*ptr)) ptr++;
+ }
+ return ptr;
+}
+
+static
+gboolean
+da_cred_match(
+ const char* key,
+ const char* str,
+ gsize len)
+{
+ return (!g_ascii_strncasecmp(key, str, len) && !key[len]);
+}
+
+gboolean
+da_cred_parse(
+ DACred* cred,
+ DACredPriv* priv,
+ const char* data,
+ gsize len)
+{
+ guint flags = 0;
+ const char* ptr = data;
+ const char* eof = data + len;
+ GPtrArray* val = g_ptr_array_new_with_free_func(g_free);
+ while (ptr < eof && (flags & PROC_PARSE_ALL) != PROC_PARSE_ALL) {
+ while (ptr < eof && g_ascii_isspace(*ptr)) ptr++;
+ if (ptr < eof) {
+ /* We are at the first non-empty character of the line */
+ const char* start = ptr;
+ while (ptr < eof && !g_ascii_isspace(*ptr) && *ptr != ':') ptr++;
+ if (ptr < eof) {
+ if (*ptr == ':') {
+ /* We've got the key */
+ const gsize keylen = ptr - start;
+ /* Skip the delimiter */
+ ptr++;
+ if (!(flags & PROC_PARSE_UID) &&
+ da_cred_match("Uid", start, keylen)) {
+ /* Real, effective, saved set, and filesystem UIDs */
+ guint32 uid;
+ flags |= PROC_PARSE_UID;
+ ptr = da_cred_parse_values(val, ptr, eof);
+ if (val->len == 4 &&
+ da_cred_parse_uint32(val->pdata[1], &uid)) {
+ flags |= PROC_PARSE_UID_OK;
+ cred->euid = uid;
+ }
+ } else if (!(flags & PROC_PARSE_GID) &&
+ da_cred_match("Gid", start, keylen)) {
+ /* Real, effective, saved set, and filesystem GIDs */
+ guint32 gid;
+ flags |= PROC_PARSE_GID;
+ ptr = da_cred_parse_values(val, ptr, eof);
+ if (val->len == 4 &&
+ da_cred_parse_uint32(val->pdata[1], &gid)) {
+ flags |= PROC_PARSE_GID_OK;
+ cred->egid = gid;
+ }
+ } else if (!(flags & PROC_PARSE_GROUPS) &&
+ da_cred_match("Groups", start, keylen)) {
+ /* Supplementary group list */
+ flags |= PROC_PARSE_GROUPS;
+ cred->flags |= DBUSACCESS_CRED_GROUPS;
+ ptr = da_cred_parse_values(val, ptr, eof);
+ if (val->len > 0) {
+ guint i;
+ priv->groups = g_new(gid_t, val->len);
+ for (i=0; i<val->len; i++) {
+ guint32 g;
+ /* Should we clear the DBUSACCESS_CRED_GROUPS
+ * if parsing fails? */
+ if (da_cred_parse_uint32(val->pdata[i], &g)) {
+ priv->groups[cred->ngroups++] = g;
+ }
+ }
+ if (cred->ngroups > 0) {
+ cred->groups = priv->groups;
+ }
+ }
+ } else if (!(flags & PROC_PARSE_CAP_EFF) &&
+ da_cred_match("CapEff", start, keylen)) {
+ /* Effective capability set */
+ flags |= PROC_PARSE_CAP_EFF;
+ ptr = da_cred_parse_values(val, ptr, eof);
+ if (val->len == 1 &&
+ da_cred_parse_uint64(val->pdata[0], &cred->caps)) {
+ cred->flags |= DBUSACCESS_CRED_CAPS;
+ }
+ }
+ }
+ /* Skip to the end of line, eat one EOL character */
+ while (ptr < eof && *ptr != '\n') ptr++;
+ if (ptr < eof) ptr++;
+ }
+ }
+ }
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_cred_p.h
^
|
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 DBUSACCESS_CRED_PRIVATE_H
+#define DBUSACCESS_CRED_PRIVATE_H
+
+#include "dbusaccess_types.h"
+
+typedef struct da_cred_priv {
+ gid_t* groups;
+} DACredPriv;
+
+gboolean
+da_cred_parse(
+ DACred* cred,
+ DACredPriv* priv,
+ const char* data,
+ gsize len);
+
+void
+da_cred_priv_cleanup(
+ DACredPriv* priv);
+
+#endif /* DBUSACCESS_CRED_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_log.h
^
|
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 DBUSACCESS_LOG_H
+#define DBUSACCESS_LOG_H
+
+#include "dbusaccess_types.h"
+
+#define GLOG_MODULE_NAME DBUSACCESS_LOG_MODULE
+#include <gutil_log.h>
+
+#endif /* DBUSACCESS_LOG_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_parser.c
^
|
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_parser_p.h"
+#include "dbusaccess_log.h"
+
+struct da_parser {
+ const DA_ACTION* actions;
+ GString* buf;
+ GSList* alloc_list;
+ GSList* link_list;
+ GSList* entries;
+};
+
+void
+da_parser_error(
+ DAParser* parser,
+ DAScanner* scanner,
+ const char* error)
+{
+ GWARN("%s", error);
+}
+
+void
+da_parser_start_string(
+ DAParser* parser)
+{
+ g_string_set_size(parser->buf, 0);
+}
+
+void
+da_parser_append_char(
+ DAParser* parser,
+ char c)
+{
+ g_string_append_c(parser->buf, c);
+}
+
+const char*
+da_parser_finish_string(
+ DAParser* parser)
+{
+ char* str = da_parser_new_string(parser, parser->buf->str);
+ g_string_set_size(parser->buf, 0);
+ return str;
+}
+
+static
+const DA_ACTION*
+da_parser_find_action(
+ DAParser* parser,
+ const char* name)
+{
+ if (name && parser->actions) {
+ const DA_ACTION* action = parser->actions;
+ while (action->name) {
+ if (!g_strcmp0(name, action->name)) {
+ return action;
+ }
+ action++;
+ }
+ }
+ return NULL;
+}
+
+GSList*
+da_parser_new_link(
+ DAParser* parser,
+ void* data)
+{
+ GSList* link = g_slist_append(NULL, NULL);
+ parser->link_list = g_slist_prepend(parser->link_list, link);
+ link->data = data;
+ return link;
+}
+
+char*
+da_parser_new_string(
+ DAParser* parser,
+ const char* str)
+{
+ char* copy = g_strdup(str);
+ parser->alloc_list = g_slist_prepend(parser->alloc_list, copy);
+ return copy;
+}
+
+DAParserExpr*
+da_parser_new_expr_identity(
+ DAParser* parser,
+ int uid,
+ int gid)
+{
+ DAParserExpr* expr = g_new(DAParserExpr,1);
+ parser->alloc_list = g_slist_prepend(parser->alloc_list, expr);
+ expr->type = DA_PARSER_EXPR_IDENTITY;
+ expr->data.identity.uid = uid;
+ expr->data.identity.gid = gid;
+ return expr;
+}
+
+DAParserExpr*
+da_parser_new_expr_custom(
+ DAParser* parser,
+ const char* name,
+ const char* param)
+{
+ const DA_ACTION* action = da_parser_find_action(parser, name);
+ if (!action) {
+ GDEBUG("Unknown action \"%s\"", name);
+ } else if (param && !action->args) {
+ GDEBUG("Unexpected parameter \"%s\" for \"%s\"", param, name);
+ } else if (!param && action->args) {
+ GDEBUG("Missing parameter for \"%s\"", name);
+ } else {
+ DAParserExpr* expr = g_new(DAParserExpr,1);
+ parser->alloc_list = g_slist_prepend(parser->alloc_list, expr);
+ expr->type = DA_PARSER_EXPR_CUSTOM;
+ expr->data.custom.action = action->id;
+ expr->data.custom.param = param;
+ return expr;
+ }
+ return NULL;
+}
+
+DAParserExpr*
+da_parser_new_expr(
+ DAParser* parser,
+ DA_PARSER_EXPR type,
+ DAParserExpr* left,
+ DAParserExpr* right)
+{
+ DAParserExpr* expr = g_new0(DAParserExpr, 1);
+ parser->alloc_list = g_slist_prepend(parser->alloc_list, expr);
+ GASSERT(type != DA_PARSER_EXPR_IDENTITY);
+ GASSERT(type != DA_PARSER_EXPR_CUSTOM);
+ expr->type = type;
+ expr->data.expr[0] = left;
+ expr->data.expr[1] = right;
+ return expr;
+}
+
+DAParserEntry*
+da_parser_new_entry(
+ DAParser* parser,
+ DAParserExpr* expr,
+ DA_ACCESS access)
+{
+ DAParserEntry* entry = g_new(DAParserEntry,1);
+ parser->alloc_list = g_slist_prepend(parser->alloc_list, entry);
+ entry->expr = expr;
+ entry->access = access;
+ return entry;
+}
+
+void
+da_parser_add_entries(
+ DAParser* parser,
+ GSList* entries)
+{
+ parser->entries = g_slist_concat(parser->entries, entries);
+}
+
+static
+DAParser*
+da_parser_create(
+ const DA_ACTION* actions)
+{
+ DAParser* parser = g_slice_new0(DAParser);
+ parser->buf = g_string_new(NULL);
+ parser->actions = actions;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_parser.h
^
|
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 DBUSACCESS_PARSER_H
+#define DBUSACCESS_PARSER_H
+
+#include "dbusaccess_policy.h"
+
+typedef struct da_parser DAParser;
+typedef struct da_parser_expr DAParserExpr;
+
+typedef enum {
+ DA_PARSER_EXPR_IDENTITY,
+ DA_PARSER_EXPR_CUSTOM,
+ DA_PARSER_EXPR_NOT,
+ DA_PARSER_EXPR_AND,
+ DA_PARSER_EXPR_OR
+} DA_PARSER_EXPR;
+
+#define DA_WILDCARD (-1) /* Matches any GID or UID */
+#define DA_INVALID (-2) /* Never matches anything, even another DA_INVALID */
+
+struct da_parser_expr {
+ DA_PARSER_EXPR type;
+ union {
+ struct {
+ int uid;
+ int gid;
+ } identity;
+ struct {
+ guint action;
+ const char* param;
+ } custom;
+ DAParserExpr* expr[2];
+ } data;
+};
+
+typedef struct da_parser_entry {
+ DAParserExpr* expr; /* NULL if wildcard */
+ DA_ACCESS access;
+} DAParserEntry;
+
+DAParser*
+da_parser_compile(
+ const char* spec,
+ const DA_ACTION* actions);
+
+GSList*
+da_parser_get_result(
+ DAParser* parser);
+
+void
+da_parser_delete(
+ DAParser* parser);
+
+#endif /* DBUSACCESS_PARSER_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_parser_p.h
^
|
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 DBUSACCESS_PARSER_PRIVATE_H
+#define DBUSACCESS_PARSER_PRIVATE_H
+
+#include "dbusaccess_parser.h"
+
+/* Stuff shared by the parser and the code generated by Bison/Flex */
+
+typedef struct yyguts_t DAScanner;
+typedef struct yy_buffer_state DAScannerBuffer;
+
+#ifdef DEBUG
+# define YYDEBUG 1
+extern int da_parser_debug;
+#endif
+
+#define YY_LEX da_parser_lex
+#define YY_DECL int YY_LEX(union YYSTYPE* yylval_param, \
+ DAScanner* yyscanner, DAParser* parser)
+
+union YYSTYPE;
+YY_DECL;
+
+/* Generated parser */
+
+void
+da_parser_error(
+ DAParser* parser,
+ DAScanner* scanner,
+ const char* error);
+
+/* Generated scanner */
+
+DAScanner*
+da_scanner_create(
+ void);
+
+void
+da_scanner_delete(
+ DAScanner* scanner);
+
+DAScannerBuffer*
+da_scanner_buffer_create(
+ const char* str,
+ DAScanner* scanner);
+
+void
+da_scanner_buffer_delete(
+ DAScannerBuffer* buffer,
+ DAScanner* scanner);
+
+int
+da_parser_parse(
+ DAParser* parser,
+ DAScanner* scanner);
+
+/* These are for the scanner */
+
+void
+da_parser_start_string(
+ DAParser* parser);
+
+void
+da_parser_append_char(
+ DAParser* parser,
+ char c);
+
+const char*
+da_parser_finish_string(
+ DAParser* parser);
+
+/* And these are for the generated parser */
+
+GSList*
+da_parser_new_link(
+ DAParser* parser,
+ void* data);
+
+char*
+da_parser_new_string(
+ DAParser* parser,
+ const char* str);
+
+DAParserExpr*
+da_parser_new_expr_identity(
+ DAParser* parser,
+ int uid,
+ int gid);
+
+DAParserExpr*
+da_parser_new_expr_custom(
+ DAParser* parser,
+ const char* name,
+ const char* param);
+
+DAParserExpr*
+da_parser_new_expr(
+ DAParser* parser,
+ DA_PARSER_EXPR type,
+ DAParserExpr* left,
+ DAParserExpr* right);
+
+DAParserEntry*
+da_parser_new_entry(
+ DAParser* parser,
+ DAParserExpr* expr,
+ DA_ACCESS access);
+
+void
+da_parser_add_entries(
+ DAParser* parser,
+ GSList* entries);
+
+#endif /* DBUSACCESS_PARSER_PRIVATE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_peer.c
^
|
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 "dbusaccess_peer.h"
+#include "dbusaccess_cred_p.h"
+#include "dbusaccess_log.h"
+
+#include <gio/gio.h>
+
+#include <gutil_macros.h>
+
+/* Log module */
+GLOG_MODULE_DEFINE("dbusaccess");
+
+#define DBUSACCESS_PEER_TIMEOUT_SEC (30)
+
+typedef struct da_peer_bus {
+ GHashTable* peers;
+ GDBusConnection* connection;
+} DAPeerBus;
+
+typedef struct da_peer_priv {
+ DAPeer pub;
+ DACredPriv cred;
+ DAPeerBus* bus;
+ char* name;
+ gint ref_count;
+ guint timeout_id;
+ guint name_watch_id;
+} DAPeerPriv;
+
+static inline DAPeerPriv* da_peer_cast(DAPeer* peer)
+ { return G_CAST(peer, DAPeerPriv, pub); }
+
+static
+void
+da_peer_unref1(
+ gpointer data)
+{
+ DAPeerPriv* priv = data;
+ da_peer_unref(&priv->pub);
+}
+
+static
+DAPeerBus*
+da_peer_bus(
+ DA_BUS type,
+ gboolean initialize)
+{
+ static DAPeerBus da_bus[2];
+ DAPeerBus* bus;
+ GBusType bus_type;
+ switch (type) {
+ case DA_BUS_SYSTEM:
+ bus = da_bus + 0;
+ bus_type = G_BUS_TYPE_SYSTEM;
+ break;
+ case DA_BUS_SESSION:
+ bus = da_bus + 1;
+ bus_type = G_BUS_TYPE_SESSION;
+ break;
+ default:
+ GERR("Invalid bus type %d", type);
+ return NULL;
+ }
+ if (!bus->connection && initialize) {
+ bus->connection = g_bus_get_sync(bus_type, NULL, NULL);
+ }
+ if (bus->connection) {
+ if (!bus->peers) {
+ bus->peers = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, da_peer_unref1);
+ }
+ return bus;
+ } else {
+ return NULL;
+ }
+}
+
+static
+void
+da_peer_dispose(
+ DAPeerPriv* priv)
+{
+ if (priv->name_watch_id) {
+ g_bus_unwatch_name(priv->name_watch_id);
+ priv->name_watch_id = 0;
+ }
+ if (priv->timeout_id) {
+ g_source_remove(priv->timeout_id);
+ priv->timeout_id = 0;
+ }
+}
+
+static
+void
+da_peer_cleanup(
+ DAPeerBus* bus)
+{
+ if (g_hash_table_size(bus->peers) == 0) {
+ g_hash_table_unref(bus->peers);
+ bus->peers = NULL;
+ if (bus->connection) {
+ g_object_unref(bus->connection);
+ bus->connection = NULL;
+ }
+ }
+}
+
+static
+void
+da_peer_remove(
+ DAPeerPriv* priv)
+{
+ DAPeerBus* bus = priv->bus;
+ da_peer_dispose(priv);
+ g_hash_table_remove(bus->peers, priv->name);
+ da_peer_cleanup(bus);
+}
+
+static
+gboolean
+da_peer_timeout(
+ gpointer data)
+{
+ DAPeerPriv* priv = data;
+ GDEBUG("Name '%s' timed out", priv->name);
+ priv->timeout_id = 0;
+ da_peer_remove(priv);
+ return G_SOURCE_REMOVE;
+}
+
+static
+void
+da_peer_vanished(
+ GDBusConnection* bus,
+ const char* name,
+ gpointer data)
+{
+ GDEBUG("Name '%s' has disappeared", name);
+ da_peer_remove(data);
+}
+static
+void
+da_peer_reset_timeout(
+ DAPeerPriv* priv)
+{
+ if (priv->timeout_id) {
+ g_source_remove(priv->timeout_id);
+ }
+ priv->timeout_id = g_timeout_add_seconds(DBUSACCESS_PEER_TIMEOUT_SEC,
+ da_peer_timeout, priv);
+}
+
+static
+DAPeerPriv*
+da_peer_new(
+ DAPeerBus* bus,
+ const char* name)
+{
+ DAPeerPriv* priv = g_slice_new0(DAPeerPriv);
+ DAPeer* peer = &priv->pub;
+ peer->name = priv->name = g_strdup(name);
+ priv->bus = bus;
+ priv->ref_count = 1;
+ da_peer_reset_timeout(priv);
+ priv->name_watch_id = g_bus_watch_name_on_connection(bus->connection, name,
+ G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, da_peer_vanished, priv, NULL);
+ return priv;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_policy.c
^
|
@@ -0,0 +1,650 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 "dbusaccess_policy.h"
+#include "dbusaccess_parser.h"
+#include "dbusaccess_log.h"
+
+#include <gutil_macros.h>
+
+typedef struct da_policy_entry DAPolicyEntry;
+typedef struct da_policy_expr DAPolicyExpr;
+
+typedef struct da_policy_check {
+ const DACred* cred;
+ guint action;
+ const char* arg;
+} DAPolicyCheck;
+
+typedef struct da_policy_expr_type {
+ gboolean (*match)(const DAPolicyExpr* x, const DAPolicyCheck* pc);
+ gboolean (*equal)(const DAPolicyExpr* x1, const DAPolicyExpr* x2);
+ void (*free)(DAPolicyExpr* expr);
+} DAPolicyExprType;
+
+struct da_policy_expr {
+ const DAPolicyExprType* type;
+};
+
+typedef struct da_policy_expr_unary {
+ DAPolicyExpr expr;
+ DAPolicyExpr* operand;
+} DAPolicyExprUnary;
+
+typedef struct da_policy_expr_binary {
+ DAPolicyExpr expr;
+ DAPolicyExpr* left;
+ DAPolicyExpr* right;
+} DAPolicyExprBinary;
+
+typedef struct da_policy_expr_custom {
+ DAPolicyExpr expr;
+ guint action;
+ GPatternSpec* pattern;
+} DAPolicyExprCustom;
+
+typedef struct da_policy_expr_identity {
+ DAPolicyExpr expr;
+ int uid;
+ int gid;
+} DAPolicyExprIdentity;
+
+struct da_policy_entry {
+ DAPolicyEntry* next;
+ DA_ACCESS access;
+ DAPolicyExpr* expr; /* NULL if wildcard */
+};
+
+struct da_policy {
+ gint ref_count;
+ DAPolicyEntry* entries;
+};
+
+/* Expressions */
+
+static inline
+gboolean
+da_policy_expr_match(
+ const DAPolicyExpr* expr,
+ const DAPolicyCheck* pc)
+{
+ /*
+ * NULL expresson matches everything! da_policy_check relies on that
+ * to handle wildcard entries. Lower-level expressions should never
+ * be NULL, the parser's grammar ensures that.
+ */
+ return !expr || expr->type->match(expr, pc);
+}
+
+static
+gboolean
+da_policy_expr_equal(
+ const DAPolicyExpr* x1,
+ const DAPolicyExpr* x2)
+{
+ if (x1 == x2) {
+ return TRUE;
+ } else if (!x1 || !x2) {
+ return FALSE;
+ } else {
+ return x1->type == x2->type && x1->type->equal(x1, x2);
+ }
+}
+
+static inline
+void
+da_policy_expr_free(
+ DAPolicyExpr* expr)
+{
+ if (expr) {
+ expr->type->free(expr);
+ }
+}
+
+/* Binary operation */
+
+static inline
+DAPolicyExprBinary*
+da_policy_expr_binary_cast(
+ const DAPolicyExpr* expr)
+{
+ return G_CAST(expr, DAPolicyExprBinary, expr);
+}
+
+static
+gboolean
+da_policy_expr_binary_and_match(
+ const DAPolicyExpr* expr,
+ const DAPolicyCheck* pc)
+{
+ DAPolicyExprBinary* x = da_policy_expr_binary_cast(expr);
+ return da_policy_expr_match(x->left, pc) &&
+ da_policy_expr_match(x->right, pc);
+}
+
+static
+gboolean
+da_policy_expr_binary_or_match(
+ const DAPolicyExpr* expr,
+ const DAPolicyCheck* pc)
+{
+ DAPolicyExprBinary* x = da_policy_expr_binary_cast(expr);
+ return da_policy_expr_match(x->left, pc) ||
+ da_policy_expr_match(x->right, pc);
+}
+
+static
+gboolean
+da_policy_expr_binary_equal(
+ const DAPolicyExpr* expr1,
+ const DAPolicyExpr* expr2)
+{
+ /* Types have been compared by the caller */
+ const DAPolicyExprBinary* x1 = da_policy_expr_binary_cast(expr1);
+ const DAPolicyExprBinary* x2 = da_policy_expr_binary_cast(expr2);
+ /* Our binary operations are commutative */
+ return (da_policy_expr_equal(x1->left, x2->left) &&
+ da_policy_expr_equal(x1->right, x2->right)) ||
+ (da_policy_expr_equal(x1->left, x2->right) &&
+ da_policy_expr_equal(x1->right, x2->left));
+}
+
+static
+void
+da_policy_expr_binary_free(
+ DAPolicyExpr* expr)
+{
+ DAPolicyExprBinary* x = da_policy_expr_binary_cast(expr);
+ da_policy_expr_free(x->left);
+ da_policy_expr_free(x->right);
+ g_slice_free(DAPolicyExprBinary, x);
+}
+
+static
+DAPolicyExpr*
+da_policy_expr_binary_new(
+ const DAPolicyExprType* type,
+ DAPolicyExpr* left,
+ DAPolicyExpr* right)
+{
+ DAPolicyExprBinary* x = g_slice_new0(DAPolicyExprBinary);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_policy1.l
^
|
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_parser_p.h"
+#include "dbusaccess_policy1.tab.h"
+#include "dbusaccess_log.h"
+
+#define YY_NO_INPUT 1
+
+static
+int
+number(
+ DAParser* parser,
+ YYSTYPE* value,
+ const char* str)
+{
+ char* endptr = NULL;
+ unsigned long n = strtoul(str, &endptr, 0);
+ if (!endptr[0]) {
+ value->number = n;
+ return NUMBER;
+ } else {
+ GDEBUG("Not a number: \"%s\"", str);
+ return ERROR;
+ }
+}
+
+%}
+%option prefix="da_parser_"
+%option never-interactive
+%option nodefault
+%option nounput
+%option noyywrap
+%option reentrant
+%option bison-bridge
+%option warn
+
+%x BEFORE_ARGS
+%x ARGS
+%x SQUOTE
+%x QUOTE
+%%
+<QUOTE>\" {
+ BEGIN(ARGS);
+ yylval->string = da_parser_finish_string(parser);
+ return STRING;
+ }
+<SQUOTE>"'" {
+ BEGIN(ARGS);
+ yylval->string = da_parser_finish_string(parser);
+ return STRING;
+ }
+<QUOTE>\\\" {
+ da_parser_append_char(parser, '"');
+ }
+<SQUOTE>"\\'" {
+ da_parser_append_char(parser, '\'');
+ }
+<QUOTE,SQUOTE>\n {
+ da_parser_append_char(parser, yytext[0]);
+ }
+<QUOTE,SQUOTE>. {
+ da_parser_append_char(parser, yytext[0]);
+ }
+<BEFORE_ARGS>"(" {
+ BEGIN(ARGS);
+ return yytext[0];
+ }
+<ARGS>"'" {
+ BEGIN(SQUOTE);
+ da_parser_start_string(parser);
+}
+<ARGS>\" {
+ BEGIN(QUOTE);
+ da_parser_start_string(parser);
+ }
+<ARGS>")" {
+ BEGIN(INITIAL);
+ return yytext[0];
+ }
+<INITIAL>user {
+ BEGIN(BEFORE_ARGS);
+ return USER;
+ }
+<INITIAL>group {
+ BEGIN(BEFORE_ARGS);
+ return GROUP;
+ }
+<INITIAL>allow {
+ return ALLOW;
+ }
+<INITIAL>deny {
+ return DENY;
+ }
+<INITIAL,ARGS>[[:digit:]]+ {
+ return number(parser, yylval, yytext);
+ }
+<ARGS>[[:alnum:]_\-?*]+ {
+ yylval->string = da_parser_new_string(parser, yytext);
+ return strcmp(yytext, "*") ? WORD : WILDCARD;
+ }
+<INITIAL>[[:alpha:]][[:alnum:]_\-]* {
+ BEGIN(BEFORE_ARGS);
+ yylval->string = da_parser_new_string(parser, yytext);
+ return ID;
+ }
+<INITIAL,BEFORE_ARGS,ARGS>[[:space:]]+ /* Eat whitespaces */;
+<INITIAL,BEFORE_ARGS,ARGS>. return yytext[0];
+%%
+
+DAScanner*
+da_scanner_create()
+{
+ yyscan_t scanner;
+ yylex_init(&scanner);
+ return scanner;
+}
+
+void
+da_scanner_delete(
+ DAScanner* scanner)
+{
+ yylex_destroy(scanner);
+}
+
+DAScannerBuffer*
+da_scanner_buffer_create(
+ const char* str,
+ DAScanner* scanner)
+{
+ return da_parser__scan_string(str, scanner);
+}
+
+void
+da_scanner_buffer_delete(
+ DAScannerBuffer* buffer,
+ DAScanner* scanner)
+{
+ da_parser__delete_buffer(buffer, scanner);
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_policy1.y
^
|
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 "dbusaccess_parser_p.h"
+#include "dbusaccess_system.h"
+#include "dbusaccess_log.h"
+#define FORMAT_VERSION 1
+%}
+
+%union
+{
+ int number;
+ const char* string;
+ DA_ACCESS access;
+ DAParserEntry* entry;
+ DAParserExpr* expr;
+ GSList* list;
+}
+
+/* BISON Declarations */
+%pure-parser
+%name-prefix "da_parser_"
+%lex-param { void* yyscanner }
+%lex-param { DAParser* parser }
+%parse-param { DAParser* parser }
+%parse-param { DAScanner* yyscanner }
+
+%token <number> NUMBER
+%token <string> ID
+%token <string> WORD
+%token <string> WILDCARD
+%token <string> STRING /* Quoted string, may include spaces */
+%token USER
+%token GROUP
+%token ALLOW
+%token DENY
+%token ERROR
+
+%type <number> version
+%type <number> user
+%type <number> group
+%type <access> access
+%type <list> entries
+%type <entry> entry
+%type <expr> expr
+%type <expr> term
+%type <string> param
+
+%left '!'
+
+/* Grammar follows */
+%%
+policy:
+ version
+ | version ';' entries
+ {
+ da_parser_add_entries(parser, $3);
+ }
+ | version ';' entries ';'
+ {
+ da_parser_add_entries(parser, $3);
+ }
+
+version:
+ NUMBER
+ {
+ if ($1 != FORMAT_VERSION) {
+ GDEBUG("Unsupported version %d", $1);
+ YYERROR;
+ }
+ }
+
+entries:
+ entry
+ {
+ $$ = da_parser_new_link(parser, $1);
+ }
+ | entries ';' entry
+ {
+ $$ = g_slist_concat($1, da_parser_new_link(parser, $3));
+ }
+
+entry:
+ '*' '=' access
+ {
+ $$ = da_parser_new_entry(parser, NULL, $3);
+ }
+ | expr '=' access
+ {
+ $$ = da_parser_new_entry(parser, $1, $3);
+ }
+ | expr
+ {
+ $$ = da_parser_new_entry(parser, $1, DA_ACCESS_ALLOW);
+ }
+
+access:
+ ALLOW
+ {
+ $$ = DA_ACCESS_ALLOW;
+ }
+ | DENY
+ {
+ $$ = DA_ACCESS_DENY;
+ }
+
+user:
+ NUMBER
+ {
+ $$ = ($1 < 0) ? DA_WILDCARD : $1;
+ }
+ | WILDCARD
+ {
+ $$ = DA_WILDCARD;
+ }
+ | WORD
+ {
+ $$ = da_system_uid($1);
+ if ($$ < 0) {
+ GWARN("Unknown user \"%s\"", $1);
+ $$ = DA_INVALID;
+ }
+ }
+
+group:
+ NUMBER
+ {
+ $$ = ($1 < 0) ? DA_WILDCARD : $1;
+ }
+ | WILDCARD
+ {
+ $$ = DA_WILDCARD;
+ }
+ | WORD
+ {
+ $$ = da_system_gid($1);
+ if ($$ < 0) {
+ GWARN("Unknown group \"%s\"", $1);
+ $$ = DA_INVALID;
+ }
+ }
+
+expr:
+ term
+ | '!' expr
+ {
+ $$ = da_parser_new_expr(parser, DA_PARSER_EXPR_NOT, $2, NULL);
+ }
+ | '(' expr ')'
+ {
+ $$ = $2;
+ }
+ | expr '|' expr
+ {
+ $$ = da_parser_new_expr(parser, DA_PARSER_EXPR_OR, $1, $3);
+ }
+ | expr '&' expr
+ {
+ $$ = da_parser_new_expr(parser, DA_PARSER_EXPR_AND, $1, $3);
+ }
+
+term:
+ USER '(' user ')'
+ {
+ $$ = da_parser_new_expr_identity(parser, $3, DA_WILDCARD);
+ }
+ | USER '(' user ':' group ')'
+ {
+ $$ = da_parser_new_expr_identity(parser, $3, $5);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_self.c
^
|
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_self.h"
+#include "dbusaccess_cred_p.h"
+#include "dbusaccess_log.h"
+
+#include <gutil_macros.h>
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+typedef struct da_self_priv {
+ DASelf pub;
+ DACredPriv cred;
+ gint ref_count;
+} DASelfPriv;
+
+static guint self_shared_timeout_id;
+static DASelf* self_shared;
+
+#define DBUSACCESS_SELF_TIMEOUT_SEC (30)
+#define DBUSACCESS_SELF_TIMEOUT_SEC_ENV "DBUSACCESS_SELF_TIMEOUT_SEC"
+
+static inline DASelfPriv* da_self_cast(DASelf* self)
+ { return G_CAST(self, DASelfPriv, pub); }
+
+DASelf*
+da_self_new(
+ void)
+{
+ DASelf* self = NULL;
+ pid_t pid = getpid();
+ char* fname = g_strdup_printf("/proc/%u/status", (guint)pid);
+ GError* error = NULL;
+ gchar* data = NULL;
+ gsize len = 0;
+ if (g_file_get_contents(fname, &data, &len, &error)) {
+ DASelfPriv* priv = g_slice_new0(DASelfPriv);
+ priv->ref_count = 1;
+ GDEBUG("Parsing %s", fname);
+ if (da_cred_parse(&priv->pub.cred, &priv->cred, data, len)) {
+ self = &priv->pub;
+ self->pid = pid;
+ } else {
+ g_slice_free(DASelfPriv, priv);
+ }
+ g_free(data);
+ } else {
+ GDEBUG("%s: %s", fname, GERRMSG(error));
+ g_error_free(error);
+ }
+ g_free(fname);
+ return self;
+}
+
+static
+gboolean
+da_self_shared_timeout(
+ gpointer data)
+{
+ GVERBOSE_("resetting shared instance");
+ GASSERT(self_shared_timeout_id);
+ GASSERT(self_shared == data);
+ self_shared_timeout_id = 0;
+ self_shared = NULL;
+ return G_SOURCE_REMOVE;
+}
+
+static
+void
+da_self_shared_unref(
+ gpointer data)
+{
+ da_self_unref(data);
+}
+
+DASelf*
+da_self_new_shared(
+ void)
+{
+ if (!self_shared) {
+ guint sec = DBUSACCESS_SELF_TIMEOUT_SEC;
+ const char* env = getenv(DBUSACCESS_SELF_TIMEOUT_SEC_ENV);
+ if (env) {
+ int interval = atoi(env);
+ if (interval >= 0) {
+ sec = interval;
+ }
+ }
+ GASSERT(!self_shared_timeout_id);
+ self_shared = da_self_new();
+ self_shared_timeout_id = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
+ sec, da_self_shared_timeout, self_shared, da_self_shared_unref);
+ }
+ return da_self_ref(self_shared);
+}
+
+static
+void
+da_self_finalize(
+ DASelfPriv* priv)
+{
+ da_cred_priv_cleanup(&priv->cred);
+}
+
+DASelf*
+da_self_ref(
+ DASelf* self)
+{
+ if (self) {
+ DASelfPriv* priv = da_self_cast(self);
+ g_atomic_int_inc(&priv->ref_count);
+ }
+ return self;
+}
+
+void
+da_self_unref(
+ DASelf* self)
+{
+ if (self) {
+ DASelfPriv* priv = da_self_cast(self);
+ if (g_atomic_int_dec_and_test(&priv->ref_count)) {
+ da_self_finalize(priv);
+ g_slice_free(DASelfPriv, priv);
+ }
+ }
+}
+
+void
+da_self_flush(
+ void)
+{
+ self_shared = NULL;
+ if (self_shared_timeout_id) {
+ g_source_remove(self_shared_timeout_id);
+ self_shared_timeout_id = 0;
+ }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/src/dbusaccess_system.c
^
|
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_system.h"
+#include "dbusaccess_log.h"
+
+#include <pwd.h>
+#include <grp.h>
+
+int
+da_system_uid(
+ const char* user)
+{
+ const struct passwd *pw = getpwnam(user);
+ if (pw) {
+ GVERBOSE_("%s => %d", user, (int)pw->pw_uid);
+ return pw->pw_uid;
+ }
+ return -1;
+}
+
+int
+da_system_gid(
+ const char* group)
+{
+ const struct group *gr = getgrnam(group);
+ if (gr) {
+ GVERBOSE_("%s => %d", group, (int)gr->gr_gid);
+ return gr->gr_gid;
+ }
+ return -1;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/Makefile
^
|
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C test_cred $*
+ @$(MAKE) -C test_policy $*
+ @$(MAKE) -C test_self $*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/common/Makefile
^
|
@@ -0,0 +1,175 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Real test makefile defines EXE (and possibly SRC) and includes this one.
+#
+
+ifndef EXE
+${error EXE not defined}
+endif
+
+SRC ?= $(EXE).c
+COMMON_SRC ?= test_main.c
+
+#
+# Required packages
+#
+
+PKGS += libglibutil glib-2.0
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Directories
+#
+
+SRC_DIR = .
+LIB_DIR = ../..
+COMMON_DIR = ../common
+BUILD_DIR = build
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Code coverage
+#
+
+ifndef GCOV
+GCOV = 0
+endif
+
+ifneq ($(GCOV),0)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+SUBMAKE_OPTS += GCOV=1
+endif
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include -I$(LIB_DIR)/src -I$(COMMON_DIR)
+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))
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = \
+ $(COMMON_SRC:%.c=$(DEBUG_BUILD_DIR)/common_%.o) \
+ $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = \
+ $(COMMON_SRC:%.c=$(RELEASE_BUILD_DIR)/common_%.o) \
+ $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LIB_PATH := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_path)
+DEBUG_LIB := $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB := $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+test_banner:
+ @echo "===========" $(EXE) "=========== "
+
+test: test_banner debug
+ @LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" $(DEBUG_EXE)
+
+valgrind: test_banner debug
+ @LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_LIB) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
+ $(LD) $(DEBUG_LDFLAGS) $(DEBUG_OBJS) $< $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_LIB) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
+ $(LD) $(RELEASE_LDFLAGS) $(RELEASE_OBJS) $< $(LIBS) -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/common/test_common.h
^
|
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016-2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 TEST_COMMON_H
+#define TEST_COMMON_H
+
+#include <gutil_types.h>
+
+#define TEST_FLAG_DEBUG (0x01)
+
+typedef struct test_opt {
+ int flags;
+} TestOpt;
+
+/* Should be invoked after g_test_init */
+void
+test_init(
+ TestOpt* opt,
+ int argc,
+ char* argv[]);
+
+#endif /* TEST_COMMON_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/common/test_main.c
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016-2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "test_common.h"
+
+#include <gutil_log.h>
+
+void
+test_init(
+ TestOpt* opt,
+ int argc,
+ char* argv[])
+{
+ int i;
+ memset(opt, 0, sizeof(*opt));
+ for (i=1; i<argc; i++) {
+ const char* arg = argv[i];
+ if (!strcmp(arg, "-d") || !strcmp(arg, "--debug")) {
+ opt->flags |= TEST_FLAG_DEBUG;
+ } else if (!strcmp(arg, "-v")) {
+ GTestConfig* config = (GTestConfig*)g_test_config_vars;
+ config->test_verbose = TRUE;
+ } else {
+ GWARN("Unsupported command line option %s", arg);
+ }
+ }
+
+ /* Setup logging */
+ gutil_log_timestamp = FALSE;
+ gutil_log_default.level = g_test_verbose() ? GLOG_LEVEL_VERBOSE :
+ GLOG_LEVEL_NONE;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/coverage/run
^
|
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# This script requires lcov to be installed
+#
+
+TESTS="\
+test_cred \
+test_policy \
+test_self"
+
+FLAVOR="release"
+
+pushd `dirname $0` > /dev/null
+COV_DIR="$PWD"
+pushd .. > /dev/null
+TEST_DIR="$PWD"
+pushd .. > /dev/null
+BASE_DIR="$PWD"
+popd > /dev/null
+popd > /dev/null
+popd > /dev/null
+
+export LD_LIBRARY_PATH="$BASE_DIR/build/$FLAVOR"
+
+make GCOV=1 -C "$BASE_DIR" clean $FLAVOR
+for t in $TESTS ; do
+ pushd "$TEST_DIR/$t"
+ make GCOV=1 -C "$TEST_DIR/$t" clean $FLAVOR || exit 1
+ build/$FLAVOR/$t || exit 1
+ popd
+done
+
+# LCOV 1.10 has branch coverage disabled per default
+LCOV_OPT="--rc lcov_branch_coverage=1"
+GENHTML_OPT="--branch-coverage"
+
+FULL_COV="$COV_DIR/full.gcov"
+LIB_COV="$COV_DIR/libdbusaccess.gcov"
+rm -f "$FULL_COV" "$LIB_COV"
+lcov $LCOV_OPT -c -d "$LD_LIBRARY_PATH" -b "$BASE_DIR" -o "$FULL_COV" || exit 1
+lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/src/*" -o "$LIB_COV" || exit 1
+genhtml $GENHTML_OPT "$LIB_COV" -t libdbusaccess --output-directory "$COV_DIR/results" || exit 1
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_cred/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_cred
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_cred/test_cred.c
^
|
@@ -0,0 +1,543 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "test_common.h"
+
+#include "dbusaccess_cred_p.h"
+
+static TestOpt test_opt;
+
+static
+void
+test_cred_parse_and_compare(
+ const DACred* expected,
+ const char* data)
+{
+ DACred cred;
+ DACredPriv priv;
+ guint i;
+ memset(&priv, 0, sizeof(priv));
+ memset(&cred, 0, sizeof(cred));
+ g_assert(da_cred_parse(&cred, &priv, data, strlen(data)));
+ g_assert(cred.euid == expected->euid);
+ g_assert(cred.egid == expected->egid);
+ g_assert(cred.caps == expected->caps);
+ g_assert(cred.flags == expected->flags);
+ g_assert(cred.ngroups == expected->ngroups);
+ for (i=0; i<cred.ngroups; i++) {
+ g_assert(cred.groups[i] == expected->groups[i]);
+ }
+ da_cred_priv_cleanup(&priv);
+}
+
+/*==========================================================================*
+ * Empty
+ *==========================================================================*/
+
+static
+void
+test_cred_empty(
+ void)
+{
+ DACred cred;
+ DACredPriv priv;
+ memset(&priv, 0, sizeof(priv));
+ memset(&cred, 0, sizeof(cred));
+ g_assert(!da_cred_parse(&cred, &priv, "", 0));
+}
+
+/*==========================================================================*
+ * Basic 1
+ *==========================================================================*/
+
+static
+void
+test_cred_basic1(
+ void)
+{
+ static const gid_t groups[] = {
+ 39, 100, 993, 996, 997, 999, 1000, 1002, 1003, 1004,
+ 1005, 1006, 1024, 100000
+ };
+ static const DACred expected = {
+ 100000, 998,
+ groups, G_N_ELEMENTS(groups),
+ 0,
+ DBUSACCESS_CRED_CAPS | DBUSACCESS_CRED_GROUPS
+ };
+ test_cred_parse_and_compare(&expected, "\
+Name: jolla-settings\n\
+State: S (sleeping)\n\
+Tgid: 9128\n\
+Pid: 9128\n\
+PPid: 1121\n\
+TracerPid: 0\n\
+Uid: 100000 100000 100000 100000\n\
+Gid: 100000 998 998 998\n\
+FDSize: 256\n\
+Groups: 39 100 993 996 997 999 1000 1002 1003 1004 1005 1006 1024 100000 \n\
+VmPeak: 163272 kB\n\
+VmSize: 144492 kB\n\
+VmLck: 0 kB\n\
+VmPin: 0 kB\n\
+VmHWM: 59688 kB\n\
+VmRSS: 49480 kB\n\
+VmData: 59360 kB\n\
+VmStk: 268 kB\n\
+VmExe: 20 kB\n\
+VmLib: 68820 kB\n\
+VmPTE: 162 kB\n\
+VmSwap: 0 kB\n\
+Threads: 11\n\
+SigQ: 0/6452\n\
+SigPnd: 0000000000000000\n\
+ShdPnd: 0000000000000000\n\
+SigBlk: 0000000000000000\n\
+SigIgn: 0000000000001000\n\
+SigCgt: 0000000180000000\n\
+CapInh: 0000000000000000\n\
+CapPrm: 0000000000000000\n\
+CapEff: 0000000000000000\n\
+CapBnd: ffffffffffffffff\n\
+Cpus_allowed: 3\n\
+Cpus_allowed_list: 0-1\n\
+voluntary_ctxt_switches: 17371\n\
+nonvoluntary_ctxt_switches: 4891\n");
+}
+
+/*==========================================================================*
+ * Basic 2
+ *==========================================================================*/
+
+static
+void
+test_cred_basic2(
+ void)
+{
+ static const DACred expected = {
+ 0, 0,
+ NULL, 0,
+ G_GUINT64_CONSTANT(0xfffffff008003420),
+ DBUSACCESS_CRED_CAPS | DBUSACCESS_CRED_GROUPS
+ };
+ test_cred_parse_and_compare(&expected, "\
+Name: connman-vpnd\n\
+State: S (sleeping)\n\
+Tgid: 24054\n\
+Pid: 24054\n\
+PPid: 1\n\
+TracerPid: 0\n\
+Uid: 0 0 0 0\n\
+Gid: 0 0 0 0\n\
+FDSize: 256\n\
+Groups: \n\
+VmPeak: 8480 kB\n\
+VmSize: 8476 kB\n\
+VmLck: 0 kB\n\
+VmPin: 0 kB\n\
+VmHWM: 2172 kB\n\
+VmRSS: 2172 kB\n\
+VmData: 340 kB\n\
+VmStk: 136 kB\n\
+VmExe: 164 kB\n\
+VmLib: 5824 kB\n\
+VmPTE: 36 kB\n\
+VmSwap: 0 kB\n\
+Threads: 1\n\
+SigQ: 0/6452\n\
+SigPnd: 0000000000000000\n\
+ShdPnd: 0000000000000000\n\
+SigBlk: 0000000000004002\n\
+SigIgn: 0000000000001000\n\
+SigCgt: 0000000180000000\n\
+CapInh: 0000000000000000\n\
+CapPrm: fffffff008003420\n\
+CapEff: fffffff008003420\n\
+CapBnd: fffffff008003420\n\
+Cpus_allowed: 3\n\
+Cpus_allowed_list: 0-1\n\
+voluntary_ctxt_switches: 48\n\
+nonvoluntary_ctxt_switches: 27\n");
+}
+
+/*==========================================================================*
+ * Garbage 1
+ *==========================================================================*/
+
+static
+void
+test_cred_garbage1(
+ void)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_policy/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_policy
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_policy/test_policy.c
^
|
@@ -0,0 +1,786 @@
+/*
+ * Copyright (C) 2017-2019 Jolla Ltd.
+ * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.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 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 "test_common.h"
+
+#include "dbusaccess_parser_p.h"
+#include "dbusaccess_policy.h"
+
+static TestOpt test_opt;
+
+#define V DA_POLICY_VERSION
+#define VPLUS "2"
+
+int
+da_system_uid(
+ const char* user)
+{
+ if (!g_strcmp0(user, "user")) {
+ return 1;
+ } else {
+ return -1;
+ }
+}
+
+int
+da_system_gid(
+ const char* group)
+{
+ if (!g_strcmp0(group, "group")) {
+ return 1;
+ } else {
+ return -1;
+ }
+}
+
+/*==========================================================================*
+ * Null
+ *==========================================================================*/
+
+static
+void
+test_policy_null(
+ void)
+{
+ static const DACred root = { 0, 0, NULL, 0, 0, 0 };
+ static const DACred user = { 1, 1, NULL, 0, 0, 0 };
+ da_policy_unref(NULL);
+ g_assert(!da_policy_ref(NULL));
+ g_assert(da_policy_check(NULL, NULL, 0, NULL, DA_ACCESS_ALLOW) ==
+ DA_ACCESS_ALLOW);
+ g_assert(da_policy_check(NULL, NULL, 0, NULL, DA_ACCESS_DENY) ==
+ DA_ACCESS_DENY);
+ g_assert(da_policy_check(NULL, &user, 0, NULL, DA_ACCESS_ALLOW) ==
+ DA_ACCESS_ALLOW);
+ g_assert(da_policy_check(NULL, &user, 0, NULL, DA_ACCESS_DENY) ==
+ DA_ACCESS_DENY);
+ /* root access is allowed even if policy is NULL! */
+ g_assert(da_policy_check(NULL, &root, 0, NULL, DA_ACCESS_DENY) ==
+ DA_ACCESS_ALLOW);
+ }
+
+/*==========================================================================*
+ * Broken
+ *==========================================================================*/
+
+static
+void
+test_policy_broken(
+ void)
+{
+ static const DA_ACTION foo [] = {
+ { "foo", 1, 1 },
+ { NULL }
+ };
+ static const DA_ACTION bar [] = {
+ { "bar", 1, 0 },
+ { NULL }
+ };
+ g_assert(!da_policy_new(NULL));
+ g_assert(!da_policy_new(""));
+ g_assert(!da_policy_new(" "));
+ g_assert(!da_policy_new("0|"));
+ g_assert(!da_policy_new("0"));
+ g_assert(!da_policy_new("0.0"));
+ g_assert(!da_policy_new(" 0 "));
+ g_assert(!da_policy_new("x"));
+ g_assert(!da_policy_new("0123456789;"));
+ g_assert(!da_policy_new(V "|+"));
+ g_assert(!da_policy_new(V ";+?=*"));
+ g_assert(!da_policy_new(VPLUS ";user(user:group)"));
+ g_assert(!da_policy_new_full(V ";foo()", foo));
+ g_assert(!da_policy_new_full(V ";bar()", foo));
+ g_assert(!da_policy_new_full(V ";bar(*)", bar));
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_policy_basic(
+ void)
+{
+ static const DA_ACTION actions [] = {
+ { "call", 1, 1 },
+ { "arg", 1, 1 },
+ { NULL }
+ };
+ /* Trivial case */
+ DAPolicy* policy = da_policy_new(V);
+ g_assert(policy);
+ g_assert(da_policy_ref(policy) == policy);
+ da_policy_unref(policy);
+ da_policy_unref(policy);
+
+ policy = da_policy_new_full(V ";user(user:group) & call(foo) & "
+ "(arg('a')|arg(\"b\"))=deny; user(baduser)=allow; "
+ "group(badgroup)=allow", actions);
+ g_assert(policy);
+ da_policy_unref(policy);
+
+ policy = da_policy_new_full(V ";user(user) & call('foo')=deny;"
+ "group(*) & call(call) = deny;"
+ "user(22) & call(call)", actions);
+ g_assert(policy);
+ da_policy_unref(policy);
+
+ policy = da_policy_new_full(V ";user(*) & !group(222) = deny; ", actions);
+ g_assert(policy);
+ da_policy_unref(policy);
+}
+
+/*==========================================================================*
+ * Groups
+ *==========================================================================*/
+
+static
+void
+test_policy_groups(
+ void)
+{
+ static const gid_t g21 [] = { 2, 1 };
+ static const gid_t g23 [] = { 2, 3 };
+ static const gid_t g43 [] = { 4, 3 };
+ static const DACred user123 = { 1, 1, g23, G_N_ELEMENTS(g23), 0, 0 };
+ static const DACred user321 = { 1, 3, g21, G_N_ELEMENTS(g21), 0, 0 };
+ static const DACred user543 = { 1, 5, g43, G_N_ELEMENTS(g43), 0, 0 };
+ DAPolicy* policy = da_policy_new(V "; group(1) | group(2) | "
+ "user(baduser:badgroup) = deny");
+
+ g_assert(policy);
+ g_assert(da_policy_check(policy, &user123, 0, NULL, DA_ACCESS_ALLOW) ==
+ DA_ACCESS_DENY);
+ g_assert(da_policy_check(policy, &user321, 0, NULL, DA_ACCESS_ALLOW) ==
+ DA_ACCESS_DENY);
+ g_assert(da_policy_check(policy, &user543, 0, NULL, DA_ACCESS_ALLOW) ==
+ DA_ACCESS_ALLOW);
+ g_assert(da_policy_check(policy, &user543, 0, NULL, DA_ACCESS_DENY) ==
+ DA_ACCESS_DENY);
+ da_policy_unref(policy);
+}
+
+/*==========================================================================*
+ * Equal1
+ *==========================================================================*/
+
+static
+void
+test_policy_equal1(
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_self/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_self
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/test/test_self/test_self.c
^
|
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "test_common.h"
+
+#include "dbusaccess_self.h"
+
+#include <stdlib.h>
+
+static TestOpt test_opt;
+
+static
+gboolean
+test_loop_quit(
+ gpointer data)
+{
+ g_main_loop_quit(data);
+ return G_SOURCE_REMOVE;
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_self_basic(
+ void)
+{
+ DASelf* self;
+
+ /* Test NULL resistance */
+ g_assert(!da_self_ref(NULL));
+ da_self_unref(NULL);
+
+ /* Actually query credentials */
+ self = da_self_new();
+ g_assert(self);
+ da_self_unref(da_self_ref(self));
+ da_self_unref(self);
+}
+
+/*==========================================================================*
+ * Shared
+ *==========================================================================*/
+
+static
+void
+test_self_shared(
+ void)
+{
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+
+ /* Allocate two instances */
+ DASelf* self1 = da_self_new_shared();
+ DASelf* self2 = da_self_new_shared();
+ g_assert(self1);
+ g_assert(self1 == self2);
+
+ /* Unref both */
+ da_self_unref(self1);
+ da_self_unref(self2);
+
+ /* Next call still returns the same pointer */
+ self1 = da_self_new_shared();
+ g_assert(self1 == self2);
+ da_self_unref(self1);
+
+ /* Clear the shared instance */
+ da_self_flush();
+ da_self_flush();
+
+ /* Set shared instance timeout to the minimum */
+ setenv("DBUSACCESS_SELF_TIMEOUT_SEC", "0", TRUE);
+
+ /* This allocates a new shared instance */
+ self1 = da_self_new_shared();
+ g_assert(self1);
+ g_assert(self1 != self2);
+
+ /* Let it expire */
+ g_timeout_add_seconds(0, test_loop_quit, loop);
+ g_main_loop_run(loop);
+
+ /* This allocates a new shared instance */
+ self2 = da_self_new_shared();
+ g_assert(self2);
+ g_assert(self1 != self2);
+
+ da_self_unref(self1);
+ da_self_unref(self2);
+ da_self_flush();
+ g_main_loop_unref(loop);
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_PREFIX "/self/"
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_PREFIX "basic", test_self_basic);
+ g_test_add_func(TEST_PREFIX "shared", test_self_shared);
+ test_init(&test_opt, argc, argv);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/tools/dbus-creds/Makefile
^
|
@@ -0,0 +1,153 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release lib-release lib-debug
+
+#
+# Required packages
+#
+
+PKGS = glib-2.0 gio-2.0 libglibutil
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Executable
+#
+
+EXE = dbus-creds
+
+#
+# Sources
+#
+
+SRC = $(EXE).c
+
+#
+# Directories
+#
+
+SRC_DIR = .
+BUILD_DIR = build
+LIB_DIR = ../..
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+WARNINGS = -Wall
+INCLUDES = -I$(LIB_DIR)/include
+BASE_FLAGS = -fPIC
+CFLAGS = $(BASE_FLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+LDFLAGS = $(BASE_FLAGS) $(shell pkg-config --libs $(PKGS))
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+
+ifndef KEEP_SYMBOLS
+KEEP_SYMBOLS = 0
+endif
+
+ifneq ($(KEEP_SYMBOLS),0)
+RELEASE_FLAGS += -g
+SUBMAKE_OPTS += KEEP_SYMBOLS=1
+endif
+
+DEBUG_LDFLAGS = $(LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_CFLAGS = $(CFLAGS) $(DEBUG_FLAGS) -DDEBUG
+RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2
+
+#
+# Files
+#
+
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
+RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
+DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
+RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
+DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
+RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+
+debug: lib-debug $(DEBUG_EXE)
+
+release: lib-release $(RELEASE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+cleaner: clean
+ @make -C $(LIB_DIR) clean
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_LIB) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
+ $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $< -o $@
+
+$(RELEASE_EXE): $(RELEASE_LIB) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
+ $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) $< -o $@
+ifeq ($(KEEP_SYMBOLS),0)
+ strip $@
+endif
+
+lib-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(DEBUG_LIB_FILE) $(DEBUG_LINK_FILE)
+
+lib-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) $(RELEASE_LIB_FILE) $(RELEASE_LINK_FILE)
+
+#
+# Install
+#
+
+INSTALL = install
+
+INSTALL_EXE_DIR = $(DESTDIR)/usr/bin
+
+install: $(INSTALL_EXE_DIR)
+ $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_EXE_DIR)
+
+$(INSTALL_EXE_DIR):
+ $(INSTALL) -d $@
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbusaccess/tools/dbus-creds/dbus-creds.c
^
|
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Contact: Slava Monich <slava.monich@jolla.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 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.
+ *
+ * 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 "dbusaccess_peer.h"
+#include <gutil_log.h>
+
+#define HELP_SUMMARY "Shows D-Bus credentials for the client specified by NAME"
+
+#define RET_OK (0)
+#define RET_NOTFOUND (1)
+#define RET_ERR (2)
+
+typedef struct app {
+ DA_BUS bus;
+ const char* name;
+} App;
+
+static
+int
+app_run(
+ App* app)
+{
+ DAPeer* peer = da_peer_get(app->bus, app->name);
+ if (peer) {
+ GDEBUG("%s bus client \"%s\"", (peer->bus == DA_BUS_SYSTEM) ?
+ "System" : "Session", peer->name);
+ printf("Pid: %d\n", peer->pid);
+ printf("Uid: %d\n", peer->cred.euid);
+ printf("Gid: %d\n", peer->cred.egid);
+ GASSERT(da_peer_get(app->bus, app->name) == peer);
+ if (peer->cred.flags & DBUSACCESS_CRED_GROUPS) {
+ GString* buf = g_string_new(NULL);
+ guint i;
+ for (i=0; i<peer->cred.ngroups; i++) {
+ if (buf->len > 0) {
+ g_string_append_c(buf, ' ');
+ }
+ g_string_append_printf(buf, "%d", peer->cred.groups[i]);
+ }
+ printf("Groups: %s\n", buf->str);
+ g_string_free(buf, TRUE);
+ }
+ if (peer->cred.flags & DBUSACCESS_CRED_CAPS) {
+ printf("Caps: 0x%016llx\n", (unsigned long long)peer->cred.caps);
+ }
+ da_peer_flush(app->bus, app->name);
+ return RET_OK;
+ } else {
+ GERR("D-Bus name \"%s\" not found", app->name);
+ return RET_NOTFOUND;
+ }
+}
+
+static
+gboolean
+app_log_verbose(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_VERBOSE;
+ return TRUE;
+}
+
+static
+gboolean
+app_log_quiet(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ gutil_log_default.level = GLOG_LEVEL_NONE;
+ return TRUE;
+}
+
+static
+gboolean
+app_init(
+ App* app,
+ int argc,
+ char* argv[])
+{
+ gboolean ok = FALSE;
+ gboolean system_bus = FALSE;
+ GOptionEntry entries[] = {
+ { "system", 0, 0, G_OPTION_ARG_NONE, &system_bus,
+ "Use system bus (default is session)", NULL },
+ { "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ app_log_verbose, "Enable verbose output", NULL },
+ { "quiet", 'q', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ app_log_quiet, "Be quiet", NULL },
+ { NULL }
+ };
+ GError* error = NULL;
+ GOptionContext* options = g_option_context_new("NAME");
+ g_option_context_set_summary(options, HELP_SUMMARY);
+ g_option_context_add_main_entries(options, entries, NULL);
+ if (g_option_context_parse(options, &argc, &argv, &error)) {
+ if (argc == 2) {
+ app->bus = system_bus ? DA_BUS_SYSTEM : DA_BUS_SESSION;
+ app->name = argv[1];
+ ok = TRUE;
+ } else {
+ char* help = g_option_context_get_help(options, TRUE, NULL);
+ fprintf(stderr, "%s", help);
+ g_free(help);
+ }
+ } else {
+ GERR("%s", error->message);
+ g_error_free(error);
+ }
+ g_option_context_free(options);
+ return ok;
+}
+
+int main(int argc, char* argv[])
+{
+ int ret = RET_ERR;
+ App app;
+ memset(&app, 0, sizeof(app));
+ gutil_log_timestamp = FALSE;
+ gutil_log_set_type(GLOG_TYPE_STDERR, "dbus-creds");
+ gutil_log_default.level = GLOG_LEVEL_DEFAULT;
+ if (app_init(&app, argc, argv)) {
+ ret = app_run(&app);
+ }
+ return ret;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/.gitignore
^
|
@@ -3,3 +3,17 @@
test/coverage/full.gcov
test/coverage/libdbuslog.gcov
test/coverage/results
+debian/dbuslog-tools.debhelper.log
+debian/dbuslog-tools.substvars
+debian/dbuslog-tools/
+debian/files
+debian/*.debhelper.log
+debian/*.substvars
+debian/*.debhelper
+debian/libdbuslogserver-common-dev
+debian/libdbuslogserver-dbus-dev
+debian/libdbuslogserver-dbus.postrm.debhelper
+debian/libdbuslogserver-dbus
+debian/libdbuslogserver-gio-dev
+debian/libdbuslogserver-gio
+debian/tmp
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/Makefile
^
|
@@ -12,7 +12,8 @@
rm -f *~ rpm/*~
rm -fr $(BUILD_DIR) RPMS installroot
rm -fr debian/tmp
- rm -fr debian/libdbuslogserver debian/libdbuslogserver-dev
- rm -fr debian/libdbuslogclient debian/libdbuslogclient-dev
+ rm -fr debian/dbuslog-tools debian/libdbuslogserver-common-dev
+ rm -fr debian/libdbuslogserver-dbus debian/libdbuslogserver-dbus-dev
+ rm -fr debian/libdbuslogserver-gio debian/libdbuslogserver-gio-dev
rm -f documentation.list debian/files debian/*.substvars
rm -f debian/*.debhelper.log debian/*.debhelper debian/*~
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/VERSION
^
|
@@ -1 +1 @@
-1.0.11
+1.0.15
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/client/include/dbuslog_client.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -56,6 +56,8 @@
DBUSLOG_LEVEL default_level;
gboolean connected;
gboolean started;
+ int api_version;
+ int backlog;
};
typedef
@@ -124,6 +126,13 @@
gpointer user_data);
DBusLogClientCall*
+dbus_log_client_set_backlog(
+ DBusLogClient* client,
+ int backlog,
+ DBusLogClientCallFunc fn,
+ gpointer user_data);
+
+DBusLogClientCall*
dbus_log_client_start(
DBusLogClient* client,
DBusLogClientCallFunc fn,
@@ -190,7 +199,7 @@
gpointer user_data);
gulong
-dbus_log_client_add_max_level_handler(
+dbus_log_client_add_backlog_handler(
DBusLogClient* client,
DBusLogClientFunc fn,
gpointer user_data);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/client/src/dbuslog_client.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -105,7 +105,7 @@
enum dbus_log_client_signal {
SIGNAL_CONNECT_ERROR,
SIGNAL_CONNECTED_CHANGED,
- SIGNAL_MAX_LEVEL_CHANGED,
+ SIGNAL_BACKLOG_CHANGED,
SIGNAL_CATEGORY_ADDED,
SIGNAL_CATEGORY_REMOVED,
SIGNAL_CATEGORY_FLAGS,
@@ -118,7 +118,7 @@
#define SIGNAL_CONNECT_ERROR_NAME "dbuslog-client-connect-error"
#define SIGNAL_CONNECTED_CHANGED_NAME "dbuslog-client-connected-changed"
-#define SIGNAL_MAX_LEVEL_CHANGED_NAME "dbuslog-client-max-level-changed"
+#define SIGNAL_BACKLOG_CHANGED_NAME "dbuslog-client-backlog-changed"
#define SIGNAL_CATEGORY_ADDED_NAME "dbuslog-client-category-added"
#define SIGNAL_CATEGORY_REMOVED_NAME "dbuslog-client-category-removed"
#define SIGNAL_CATEGORY_FLAGS_NAME "dbuslog-client-category-flags"
@@ -492,14 +492,18 @@
void
dbus_log_client_init_free(
DBusLogClientInit* init,
- gboolean ok)
+ GError* error)
{
if (init) {
DBusLogClient* self = init->client;
DBusLogClientPriv* priv = self->priv;
if (priv->init == init) {
priv->init = NULL;
- if (ok) {
+ if (error) {
+ /* Failed to connect */
+ GERR("%s", GERRMSG(error));
+ dbus_log_client_emit(self, SIGNAL_CONNECT_ERROR, error);
+ } else {
/* Replace the public array */
g_ptr_array_unref(self->categories);
self->categories = dbus_log_category_values(init->categories);
@@ -519,6 +523,9 @@
if (init->categories) {
g_hash_table_destroy(init->categories);
}
+ if (error) {
+ g_error_free(error);
+ }
g_object_unref(init->bus);
g_object_unref(init->cancel);
g_slice_free(DBusLogClientInit, init);
@@ -528,48 +535,107 @@
static
void
+dbus_log_client_decode_categories(
+ DBusLogClientInit* init,
+ GVariant* cats)
+{
+ GVariantIter it;
+ GVariant* child;
+ GDEBUG("%u categories", (guint)g_variant_n_children(cats));
+ for (g_variant_iter_init(&it, cats);
+ (child = g_variant_iter_next_value(&it)) != NULL;
+ g_variant_unref(child)) {
+ DBusLogCategory* cat;
+ const char* name = NULL;
+ guint id = 0, flags = 0;
+ gint level = 0;
+ g_variant_get(child, "(&suui)", &name, &id, &flags, &level);
+ cat = dbus_log_category_new(name, id);
+ cat->flags = flags;
+ cat->level = level;
+ /* Hashtable takes ownership of this DBusLogCategory */
+ g_hash_table_replace(init->categories, GINT_TO_POINTER(id), cat);
+ }
+}
+
+static
+void
dbus_log_client_init_get_all_finished(
GObject* proxy,
GAsyncResult* result,
gpointer data)
{
- GError* error = NULL;
DBusLogClientInit* init = data;
+ GError* error = NULL;
gint version;
gint default_level;
- GVariant* list = NULL;
+ GVariant* cats = NULL;
GASSERT(ORG_NEMOMOBILE_LOGGER(proxy) == init->proxy);
if (org_nemomobile_logger_call_get_all_finish(init->proxy, &version,
- &default_level, &list, result, &error)) {
- GVariantIter it;
- GVariant* child;
-
- /* Decode categories */
- GDEBUG("%u categories", (guint)g_variant_n_children(list));
- for (g_variant_iter_init(&it, list);
- (child = g_variant_iter_next_value(&it)) != NULL;
- g_variant_unref(child)) {
- DBusLogCategory* cat;
- const char* name = NULL;
- guint id = 0, flags = 0;
- gint level = 0;
- g_variant_get(child, "(&suui)", &name, &id, &flags, &level);
- cat = dbus_log_category_new(name, id);
- cat->flags = flags;
- cat->level = level;
- /* Hashtable takes ownership of this DBusLogCategory */
- g_hash_table_replace(init->categories, GINT_TO_POINTER(id), cat);
- }
- g_variant_unref(list);
+ &default_level, &cats, result, &error)) {
+ dbus_log_client_decode_categories(init, cats);
+ g_variant_unref(cats);
init->client->default_level = default_level;
+ /* Done with init. This emits the CONNECTED signal */
+ dbus_log_client_init_free(init, NULL);
+ } else {
+ dbus_log_client_init_free(init, error);
+ }
+}
+static
+void
+dbus_log_client_init_get_all2_finished(
+ GObject* proxy,
+ GAsyncResult* result,
+ gpointer data)
+{
+ DBusLogClientInit* init = data;
+ GError* error = NULL;
+ gint version, default_level, backlog;
+ GVariant* cats = NULL;
+ GASSERT(ORG_NEMOMOBILE_LOGGER(proxy) == init->proxy);
+ if (org_nemomobile_logger_call_get_all2_finish(init->proxy, &version,
+ &default_level, &cats, &backlog, result, &error)) {
+ DBusLogClient* client = init->client;
+ dbus_log_client_decode_categories(init, cats);
+ g_variant_unref(cats);
+ client->default_level = default_level;
+ client->backlog = backlog;
/* Done with init. This emits the CONNECTED signal */
- dbus_log_client_init_free(init, TRUE);
+ dbus_log_client_init_free(init, NULL);
} else {
- GERR("%s", GERRMSG(error));
- dbus_log_client_emit(init->client, SIGNAL_CONNECT_ERROR, error);
- g_error_free(error);
- dbus_log_client_init_free(init, FALSE);
+ dbus_log_client_init_free(init, error);
+ }
+}
+
+static
+void
+dbus_log_client_init_get_interface_version_finished(
+ GObject* proxy,
+ GAsyncResult* result,
+ gpointer data)
+{
+ DBusLogClientInit* init = data;
+ GError* error = NULL;
+ gint version;
+ GASSERT(ORG_NEMOMOBILE_LOGGER(proxy) == init->proxy);
+ if (org_nemomobile_logger_call_get_interface_version_finish(init->proxy,
+ &version,result, &error)) {
+ init->client->api_version = version;
+ switch (version) {
+ case 1:
+ org_nemomobile_logger_call_get_all(init->proxy, init->cancel,
+ dbus_log_client_init_get_all_finished, init);
+ break;
+ case 2:
+ default:
+ org_nemomobile_logger_call_get_all2(init->proxy, init->cancel,
+ dbus_log_client_init_get_all2_finished, init);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/changelog
^
|
@@ -0,0 +1,25 @@
+libdbuslog (1.0.15) unstable; urgency=low
+
+ * Allow to configure backlog over D-Bus
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 18 Nov 2018 02:54:03 +0200
+
+libdbuslog (1.0.14) unstable; urgency=low
+
+ * Added dbus_log_server_add_default_level_handler() function
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 04 Nov 2018 02:05:48 +0300
+
+libdbuslog (1.0.13) unstable; urgency=low
+
+ * Added pkgconfig files to debian packages
+ * Fixed dbuslog-client permissions
+ * Added dbus_log_server_remove_all_handlers macro
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 02 Nov 2018 01:19:11 +0300
+
+libdbuslog (1.0.12) unstable; urgency=low
+
+ * Added debian packaging
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 01 Nov 2018 12:07:55 +0300
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/compat
^
|
@@ -0,0 +1 @@
+5
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/control
^
|
@@ -0,0 +1,41 @@
+Source: libdbuslog
+Section: libs
+Priority: optional
+Maintainer: Slava Monich <slava.monich@jolla.com>
+Build-Depends: debhelper (>= 7), libglib2.0-dev (>= 2.0), libdbus-1-dev, libglibutil-dev, libdbusaccess-dev
+Standards-Version: 3.8.4
+
+Package: libdbuslogserver-common-dev
+Section: libdevel
+Architecture: any
+Description: Common development files for libdbuslogserver-dbus-devel and libdbuslogserver-gio-devel
+
+Package: libdbuslogserver-dbus
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Library of logging utilities for libdbus based programs
+
+Package: libdbuslogserver-dbus-dev
+Section: libdevel
+Architecture: any
+Depends: libdbuslogserver-dbus(= ${binary:Version}), libdbuslogserver-common-dev(= ${binary:Version}), ${misc:Depends}
+Description: Development files for libdbusaccess
+
+Package: libdbuslogserver-gio
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Library of logging utilities for libdbus based programs
+
+Package: libdbuslogserver-gio-dev
+Section: libdevel
+Architecture: any
+Depends: libdbuslogserver-gio(= ${binary:Version}), libdbuslogserver-common-dev(= ${binary:Version}), ${misc:Depends}
+Description: Development files for libdbusaccess
+
+Package: dbuslog-tools
+Section: utils
+Architecture: any
+Depends: libdbusaccess, ${shlibs:Depends}, ${misc:Depends}
+Description: D-Bus logging tools
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/copyright
^
|
@@ -0,0 +1,29 @@
+Copyright (C) 2016-2018 Jolla Ltd.
+Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.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 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.
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/dbuslog-tools.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/bin/* usr/bin
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/libdbuslogserver-common-dev.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/include/dbuslogserver/*.h usr/include/dbuslogserver
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/libdbuslogserver-dbus-dev.install
^
|
@@ -0,0 +1,3 @@
+debian/tmp/usr/lib/libdbuslogserver-dbus.so usr/lib
+debian/tmp/usr/include/dbuslogserver/dbus/*.h usr/include/dbuslogserver/dbus
+debian/tmp/usr/lib/pkgconfig/libdbuslogserver-dbus.pc usr/lib/pkgconfig
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/libdbuslogserver-dbus.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libdbuslogserver-dbus.so.* usr/lib
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/libdbuslogserver-gio-dev.install
^
|
@@ -0,0 +1,3 @@
+debian/tmp/usr/lib/libdbuslogserver-gio.so usr/lib
+debian/tmp/usr/include/dbuslogserver/gio/*.h usr/include/dbuslogserver/gio
+debian/tmp/usr/lib/pkgconfig/libdbuslogserver-gio.pc usr/lib/pkgconfig
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/libdbuslogserver-gio.install
^
|
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libdbuslogserver-gio.so.* usr/lib
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/rules
^
|
@@ -0,0 +1,25 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+DBUSLOG_CLIENT_DIR=tools/dbuslog-client
+
+override_dh_auto_clean:
+ dh_auto_clean -- -C test
+ dh_auto_clean -- -C common
+ dh_auto_clean -- -C client
+ dh_auto_clean -- -C server
+ dh_auto_clean -- -C $(DBUSLOG_CLIENT_DIR)
+
+override_dh_auto_build:
+ dh_auto_build -- -C server release pkgconfig
+ dh_auto_build -- -C $(DBUSLOG_CLIENT_DIR) release
+
+override_dh_auto_install:
+ dh_auto_install -- -C $(DBUSLOG_CLIENT_DIR)
+ dh_auto_install -- -C server
+
+%:
+ dh $@
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/source/format
^
|
@@ -0,0 +1 @@
+1.0
|
[-]
[+]
|
Added |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/debian/source/options
^
|
@@ -0,0 +1 @@
+tar-ignore = ".git"
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/rpm/libdbuslog.spec
^
|
@@ -1,5 +1,5 @@
Name: dbuslog-tools
-Version: 1.0.11
+Version: 1.0.15
Release: 0
Summary: Command line client for libdbuslogserver
Group: Development/Tools
@@ -22,18 +22,15 @@
%build
make -C tools/dbuslog-client KEEP_SYMBOLS=1 release
-make -C server KEEP_SYMBOLS=1 dbus-release dbus-pkgconfig
-make -C server KEEP_SYMBOLS=1 gio-release gio-pkgconfig
+make -C server KEEP_SYMBOLS=1 release pkgconfig
%check
make -C test test
%install
rm -rf %{buildroot}
-make -C server dbus-install-dev DESTDIR=%{buildroot}
-make -C server gio-install-dev DESTDIR=%{buildroot}
-install -d %{buildroot}/%{_bindir}
-install -m 755 tools/dbuslog-client/build/release/dbuslog-client %{buildroot}/%{_bindir}
+make -C tools/dbuslog-client install DESTDIR=%{buildroot}
+make -C server install DESTDIR=%{buildroot}
%files
%defattr(-,root,root,-)
@@ -41,6 +38,20 @@
#############################################################################
+%package -n libdbuslogserver-common-devel
+Summary: Common development files
+Group: Development/Libraries
+
+%description -n libdbuslogserver-common-devel
+This package contains development files shared by libdbuslogserver-dbus-devel
+and libdbuslogserver-gio-devel.
+
+%files -n libdbuslogserver-common-devel
+%defattr(-,root,root,-)
+%{_includedir}/dbuslogserver/*.h
+
+#############################################################################
+
%package -n libdbuslogserver-dbus
Summary: Library of logging utilities for libdbus based programs
Group: Development/Libraries
@@ -54,6 +65,7 @@
%package -n libdbuslogserver-dbus-devel
Summary: Development library for libdbuslogserver-dbus
+Requires: libdbuslogserver-common-devel = %{version}
Requires: libdbuslogserver-dbus = %{version}
Requires: pkgconfig
@@ -72,7 +84,7 @@
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/libdbuslogserver-dbus.pc
%{_libdir}/libdbuslogserver-dbus.so
-%{_includedir}/dbuslogserver-dbus/*.h
+%{_includedir}/dbuslogserver/dbus/*.h
#############################################################################
@@ -88,6 +100,7 @@
%package -n libdbuslogserver-gio-devel
Summary: Development library for libdbuslogserver-gio
+Requires: libdbuslogserver-common-devel = %{version}
Requires: libdbuslogserver-gio = %{version}
Requires: pkgconfig
@@ -106,4 +119,4 @@
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/libdbuslogserver-gio.pc
%{_libdir}/libdbuslogserver-gio.so
-%{_includedir}/dbuslogserver-gio/*.h
+%{_includedir}/dbuslogserver/gio/*.h
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/Makefile
^
|
@@ -2,6 +2,9 @@
.PHONY: clean all debug release pkgconfig
.PHONY: common_debug common_release
+.PHONY: common-install-dev install
+.PHONY: dbus-install dbus-install-dev
+.PHONY: gio-install gio-install-dev
#
# Required packages
@@ -346,31 +349,31 @@
# Install
#
-INSTALL_PERM = 644
-INSTALL_OWNER = $(shell id -u)
-INSTALL_GROUP = $(shell id -g)
-
INSTALL = install
INSTALL_DIRS = $(INSTALL) -d
-INSTALL_FILES = $(INSTALL) -m $(INSTALL_PERM)
+INSTALL_FILES = $(INSTALL) -m 644
INSTALL_LIB_DIR = $(DESTDIR)/usr/lib
INSTALL_PKGCONFIG_DIR = $(DESTDIR)/usr/lib/pkgconfig
-INSTALL_INCLUDE_DIR = $(DESTDIR)/usr/include
-DBUS_INSTALL_INCLUDE_DIR = $(INSTALL_INCLUDE_DIR)/$(DBUS_NAME)
-GIO_INSTALL_INCLUDE_DIR = $(INSTALL_INCLUDE_DIR)/$(GIO_NAME)
+INSTALL_INCLUDE_DIR = $(DESTDIR)/usr/include/dbuslogserver
+DBUS_INSTALL_INCLUDE_DIR = $(INSTALL_INCLUDE_DIR)/dbus
+GIO_INSTALL_INCLUDE_DIR = $(INSTALL_INCLUDE_DIR)/gio
INSTALL_ALIAS = $(INSTALL_LIB_DIR)/$(LIB_SHORTCUT)
+install: dbus-install-dev gio-install-dev
+
+common-install-dev: $(INSTALL_INCLUDE_DIR)
+ $(INSTALL_FILES) $(INCLUDE_DIR)/*.h $(INSTALL_INCLUDE_DIR)
+ $(INSTALL_FILES) $(COMMON_INCLUDE_DIR)/dbuslog_protocol.h $(INSTALL_INCLUDE_DIR)
+
dbus-install: $(INSTALL_LIB_DIR)
$(INSTALL_FILES) $(DBUS_RELEASE_LIB) $(INSTALL_LIB_DIR)
ln -sf $(DBUS_LIB) $(INSTALL_LIB_DIR)/$(DBUS_LIB_SYMLINK2)
ln -sf $(DBUS_LIB_SYMLINK2) $(INSTALL_LIB_DIR)/$(DBUS_LIB_SYMLINK1)
-dbus-install-dev: dbus-install $(DBUS_INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
- $(INSTALL_FILES) $(INCLUDE_DIR)/*.h $(DBUS_INSTALL_INCLUDE_DIR)
+dbus-install-dev: dbus-install common-install-dev $(DBUS_INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
$(INSTALL_FILES) $(DBUS_INCLUDE_DIR)/*.h $(DBUS_INSTALL_INCLUDE_DIR)
- $(INSTALL_FILES) $(COMMON_INCLUDE_DIR)/dbuslog_protocol.h $(DBUS_INSTALL_INCLUDE_DIR)
$(INSTALL_FILES) $(DBUS_PKGCONFIG) $(INSTALL_PKGCONFIG_DIR)
ln -sf $(DBUS_LIB_SYMLINK1) $(INSTALL_LIB_DIR)/$(DBUS_LIB_DEV_SYMLINK)
@@ -379,16 +382,17 @@
ln -sf $(GIO_LIB) $(INSTALL_LIB_DIR)/$(GIO_LIB_SYMLINK2)
ln -sf $(GIO_LIB_SYMLINK2) $(INSTALL_LIB_DIR)/$(GIO_LIB_SYMLINK1)
-gio-install-dev: gio-install $(GIO_INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
- $(INSTALL_FILES) $(INCLUDE_DIR)/*.h $(GIO_INSTALL_INCLUDE_DIR)
+gio-install-dev: gio-install common-install-dev $(GIO_INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
$(INSTALL_FILES) $(GIO_INCLUDE_DIR)/*.h $(GIO_INSTALL_INCLUDE_DIR)
- $(INSTALL_FILES) $(COMMON_INCLUDE_DIR)/dbuslog_protocol.h $(GIO_INSTALL_INCLUDE_DIR)
$(INSTALL_FILES) $(GIO_PKGCONFIG) $(INSTALL_PKGCONFIG_DIR)
ln -sf $(GIO_LIB_SYMLINK1) $(INSTALL_LIB_DIR)/$(GIO_LIB_DEV_SYMLINK)
$(INSTALL_LIB_DIR):
$(INSTALL_DIRS) $@
+$(INSTALL_INCLUDE_DIR):
+ $(INSTALL_DIRS) $@
+
$(DBUS_INSTALL_INCLUDE_DIR):
$(INSTALL_DIRS) $@
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/include/dbuslog_server.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -55,6 +55,13 @@
DBUSLOG_LEVEL level,
gpointer user_data);
+typedef
+void
+(*DBusLogServerLogLevelFunc)(
+ DBusLogServer* server,
+ DBUSLOG_LEVEL level,
+ gpointer user_data);
+
DBusLogServer*
dbus_log_server_ref(
DBusLogServer* server);
@@ -136,6 +143,12 @@
DBusLogServerCategoryLevelFunc fn,
gpointer user_data);
+gulong
+dbus_log_server_add_default_level_handler(
+ DBusLogServer* server,
+ DBusLogServerLogLevelFunc fn,
+ gpointer user_data); /* since 1.0.14 */
+
void
dbus_log_server_remove_handler(
DBusLogServer* server,
@@ -147,6 +160,9 @@
gulong* ids,
guint count);
+#define dbus_log_server_remove_all_handlers(server,ids) \
+ dbus_log_server_remove_handlers(server, ids, G_N_ELEMENTS(ids))
+
G_END_DECLS
#endif /* DBUSLOG_SERVER_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/libdbuslogserver-dbus.pc.in
^
|
@@ -1,10 +1,11 @@
name=dbuslogserver-dbus
libdir=/usr/lib
includedir=/usr/include
+rootincludedir=/usr/include/dbuslogserver
Name: libdbuslogserver-dbus
Description: D-Bus Log server (libdbus-based)
Version: [version]
Requires: libglibutil glib-2.0 dbus-1
Libs: -L${libdir} -l${name}
-Cflags: -I${includedir} -I${includedir}/${name}
+Cflags: -I${includedir} -I${rootincludedir} -I${rootincludedir}/dbus
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/libdbuslogserver-gio.pc.in
^
|
@@ -1,10 +1,11 @@
name=dbuslogserver-gio
libdir=/usr/lib
includedir=/usr/include
+rootincludedir=/usr/include/dbuslogserver
Name: libdbuslogserver-gio
Description: D-Bus Log server (libgio-based)
Version: [version]
Requires: libglibutil glib-2.0 gio-2.0
Libs: -L${libdir} -l${name}
-Cflags: -I${includedir} -I${includedir}/${name}
+Cflags: -I${includedir} -I${rootincludedir} -I${rootincludedir}/gio
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbus/dbuslog_server_dbus.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -223,22 +223,20 @@
}
static
-DBusMessage*
-dbus_log_server_dbus_handle_get_all(
+void
+dbus_log_server_dbus_append_get_all(
DBusLogServerDbus* self,
- DBusMessage* msg)
+ DBusMessageIter* it)
{
DBusLogCore* core = self->server.core;
GPtrArray* cats = dbus_log_core_get_categories(core);
- DBusMessage* reply = dbus_message_new_method_return(msg);
- DBusMessageIter it, a;
+ DBusMessageIter a;
guint i;
const dbus_int32_t version = DBUSLOG_INTERFACE_VERSION;
const dbus_int32_t loglevel = dbus_log_core_default_level(core);
- dbus_message_iter_init_append(reply, &it);
- dbus_message_iter_append_basic(&it, DBUS_TYPE_INT32, &version);
- dbus_message_iter_append_basic(&it, DBUS_TYPE_INT32, &loglevel);
- dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY, "(suui)", &a);
+ dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &version);
+ dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &loglevel);
+ dbus_message_iter_open_container(it, DBUS_TYPE_ARRAY, "(suui)", &a);
for (i=0; i<cats->len; i++) {
DBusMessageIter s;
DBusLogCategory* cat = g_ptr_array_index(cats, i);
@@ -252,7 +250,44 @@
dbus_message_iter_append_basic(&s, DBUS_TYPE_INT32, &level);
dbus_message_iter_close_container(&a, &s);
}
- dbus_message_iter_close_container(&it, &a);
+ dbus_message_iter_close_container(it, &a);
+}
+
+static
+DBusMessage*
+dbus_log_server_dbus_handle_get_all(
+ DBusLogServerDbus* self,
+ DBusMessage* msg)
+{
+ DBusMessageIter it;
+ DBusMessage* reply = dbus_message_new_method_return(msg);
+ dbus_message_iter_init_append(reply, &it);
+ dbus_log_server_dbus_append_get_all(self, &it);
+ return reply;
+}
+
+static
+void
+dbus_log_server_dbus_append_get_all2(
+ DBusLogServerDbus* self,
+ DBusMessageIter* it)
+{
+ DBusLogCore* core = self->server.core;
+ const dbus_int32_t backlog = dbus_log_core_backlog(core);
+ dbus_log_server_dbus_append_get_all(self, it);
+ dbus_message_iter_append_basic(it, DBUS_TYPE_INT32, &backlog);
+}
+
+static
+DBusMessage*
+dbus_log_server_dbus_handle_get_all2(
+ DBusLogServerDbus* self,
+ DBusMessage* msg)
+{
+ DBusMessageIter it;
+ DBusMessage* reply = dbus_message_new_method_return(msg);
+ dbus_message_iter_init_append(reply, &it);
+ dbus_log_server_dbus_append_get_all2(self, &it);
return reply;
}
@@ -443,6 +478,23 @@
}
static
+DBusMessage*
+dbus_log_server_dbus_handle_set_backlog(
+ DBusLogServerDbus* self,
+ DBusMessage* msg)
+{
+ int err = -EINVAL;
+ dbus_int32_t backlog = 0;
+ if (dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_INT32, &backlog,
+ DBUS_TYPE_INVALID)) {
+ err = dbus_log_server_call_set_backlog(&self->server,
+ dbus_message_get_sender(msg), backlog);
+ }
+ return dbus_log_server_return(msg, err);
+}
+
+static
void
dbus_log_server_dbus_emit_default_level_changed(
DBusLogServer* server)
@@ -552,6 +604,26 @@
}
static
+void
+dbus_log_server_dbus_emit_backlog_changed(
+ DBusLogServer* server,
+ int backlog)
+{
+ DBusLogServerDbus* self = DBUSLOG_SERVER_DBUS(server);
+ DBusMessage* signal = dbus_message_new_signal(server->path,
+ DBUSLOG_INTERFACE, "BacklogChanged");
+ if (signal) {
+ const dbus_int32_t value = backlog;
+ if (dbus_message_append_args(signal,
+ DBUS_TYPE_INT32, &value,
+ DBUS_TYPE_INVALID)) {
+ dbus_connection_send(self->conn, signal, NULL);
+ }
+ dbus_message_unref(signal);
+ }
+}
+
+static
DBusHandlerResult
dbus_log_server_dbus_filter(
DBusConnection* conn,
@@ -575,6 +647,9 @@
"GetAll", "",
dbus_log_server_dbus_handle_get_all
},{
+ "GetAll2", "",
+ dbus_log_server_dbus_handle_get_all2
+ },{
"SetDefaultLevel", "i",
dbus_log_server_dbus_handle_set_default_level
},{
@@ -594,10 +669,13 @@
dbus_log_server_dbus_handle_category_enable_pattern
},{
"CategoryDisable", "as",
- dbus_log_server_dbus_handle_category_disable
+ dbus_log_server_dbus_handle_category_disable
},{
"CategoryDisablePattern", "s",
dbus_log_server_dbus_handle_category_disable_pattern
+ },{
+ "SetBacklog", "i",
+ dbus_log_server_dbus_handle_set_backlog
}
};
guint i;
@@ -740,6 +818,7 @@
klass->emit_category_removed = dbus_log_server_dbus_emit_category_removed;
klass->emit_category_flags_changed =
dbus_log_server_dbus_emit_category_flags_changed;
+ klass->emit_backlog_changed = dbus_log_server_dbus_emit_backlog_changed;
G_OBJECT_CLASS(klass)->finalize = dbus_log_server_dbus_finalize;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_core.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -61,6 +61,7 @@
DBUSLOG_CORE_TYPE, DBusLogCore))
enum dbus_log_core_signal {
+ SIGNAL_BACKLOG,
SIGNAL_DEFAULT_LEVEL,
SIGNAL_CATEGORY_ADDED,
SIGNAL_CATEGORY_REMOVED,
@@ -69,6 +70,7 @@
SIGNAL_COUNT
};
+#define SIGNAL_BACKLOG_NAME "dbuslog-core-backlog"
#define SIGNAL_DEFAULT_LEVEL_NAME "dbuslog-core-default-level"
#define SIGNAL_CATEGORY_ADDED_NAME "dbuslog-core-category-added"
#define SIGNAL_CATEGORY_REMOVED_NAME "dbuslog-core-category-removed"
@@ -119,7 +121,7 @@
guint backlog)
{
DBusLogCore* self = g_object_new(DBUSLOG_CORE_TYPE, NULL);
- self->backlog = backlog;
+ self->backlog = dbus_log_sender_normalize_backlog(backlog);
return self;
}
@@ -262,6 +264,34 @@
return FALSE;
}
+int
+dbus_log_core_backlog(
+ DBusLogCore* self)
+{
+ return G_LIKELY(self) ? self->backlog : 0;
+}
+
+void
+dbus_log_core_set_backlog(
+ DBusLogCore* self,
+ int backlog)
+{
+ if (G_LIKELY(self)) {
+ backlog = dbus_log_sender_normalize_backlog(backlog);
+ if (self->backlog != backlog) {
+ GPtrArray* senders = self->senders;
+ guint i;
+
+ self->backlog = backlog;
+ for (i = 0; i < senders->len; i++) {
+ dbus_log_sender_set_backlog(g_ptr_array_index(senders, i),
+ backlog);
+ }
+ g_signal_emit(self, dbus_log_core_signals[SIGNAL_BACKLOG], 0);
+ }
+ }
+}
+
DBusLogCategory*
dbus_log_core_new_category(
DBusLogCore* self,
@@ -529,6 +559,16 @@
}
gulong
+dbus_log_core_add_backlog_handler(
+ DBusLogCore* self,
+ DBusLogCoreFunc fn,
+ gpointer data)
+{
+ return (G_LIKELY(self) && G_LIKELY(fn)) ? g_signal_connect(self,
+ SIGNAL_BACKLOG_NAME, G_CALLBACK(fn), data) : 0;
+}
+
+gulong
dbus_log_core_add_default_level_handler(
DBusLogCore* self,
DBusLogCoreFunc fn,
@@ -679,6 +719,10 @@
g_signal_new(SIGNAL_DEFAULT_LEVEL_NAME,
class_type, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ dbus_log_core_signals[SIGNAL_BACKLOG] =
+ g_signal_new(SIGNAL_BACKLOG_NAME,
+ class_type, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
dbus_log_core_signals[SIGNAL_CATEGORY_ADDED] =
g_signal_new(SIGNAL_CATEGORY_ADDED_NAME,
class_type, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_core.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -91,6 +91,15 @@
DBusLogCore* core,
DBUSLOG_LEVEL level);
+int
+dbus_log_core_backlog(
+ DBusLogCore* core);
+
+void
+dbus_log_core_set_backlog(
+ DBusLogCore* core,
+ int backlog);
+
DBusLogCategory*
dbus_log_core_new_category(
DBusLogCore* core,
@@ -151,6 +160,12 @@
/* Signals */
gulong
+dbus_log_core_add_backlog_handler(
+ DBusLogCore* core,
+ DBusLogCoreFunc fn,
+ gpointer data);
+
+gulong
dbus_log_core_add_default_level_handler(
DBusLogCore* core,
DBusLogCoreFunc fn,
@@ -191,6 +206,9 @@
gulong* ids,
guint count);
+#define dbus_log_core_remove_all_handlers(core,ids) \
+ dbus_log_core_remove_handlers(core, ids, G_N_ELEMENTS(ids))
+
#endif /* DBUSLOG_CORE_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_sender.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -317,9 +317,9 @@
DBusLogSenderPriv* priv = self->priv;
int writefd = pipefd[1];
self->readfd = pipefd[0];
- priv->buffer = gutil_ring_new_full(0, (backlog > 0) ? backlog :
- (backlog == 0) ? DBUSLOG_SENDER_DEFAULT_BACKLOG :
- GUTIL_RING_UNLIMITED_SIZE, dbus_log_sender_buffer_free_func);
+ priv->buffer = gutil_ring_new_full(0,
+ dbus_log_sender_normalize_backlog(backlog),
+ dbus_log_sender_buffer_free_func);
self->name = priv->name = g_strdup(name);
priv->io = g_io_channel_unix_new(writefd);
if (priv->io) {
@@ -358,6 +358,19 @@
}
}
+void
+dbus_log_sender_set_backlog(
+ DBusLogSender* self,
+ int backlog)
+{
+ if (G_LIKELY(self)) {
+ DBusLogSenderPriv* priv = self->priv;
+
+ gutil_ring_set_max_size(priv->buffer,
+ dbus_log_sender_normalize_backlog(backlog));
+ }
+}
+
gboolean
dbus_log_sender_ping(
DBusLogSender* self)
@@ -446,8 +459,8 @@
g_io_channel_shutdown(priv->io, flush, NULL);
g_io_channel_unref(priv->io);
priv->io = NULL;
- g_signal_emit(self, dbus_log_sender_signals[
- DBUSLOG_SENDER_SIGNAL_CLOSED], 0);
+ g_signal_emit(self, dbus_log_sender_signals
+ [DBUSLOG_SENDER_SIGNAL_CLOSED], 0);
}
}
}
@@ -472,6 +485,15 @@
}
}
+int
+dbus_log_sender_normalize_backlog(
+ int backlog)
+{
+ return (backlog > 0) ? backlog :
+ (backlog == 0) ? DBUSLOG_SENDER_DEFAULT_BACKLOG :
+ GUTIL_RING_UNLIMITED_SIZE;
+}
+
/*==========================================================================*
* Internals
*==========================================================================*/
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_sender.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -66,6 +66,11 @@
dbus_log_sender_unref(
DBusLogSender* sender);
+void
+dbus_log_sender_set_backlog(
+ DBusLogSender* sender,
+ int backlog);
+
gboolean
dbus_log_sender_ping(
DBusLogSender* sender);
@@ -96,6 +101,10 @@
DBusLogSender* sender,
gulong id);
+int
+dbus_log_sender_normalize_backlog(
+ int backlog);
+
#endif /* DBUSLOG_SENDER_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_server.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -39,6 +39,7 @@
#include <errno.h>
enum dbus_log_server_core_signal {
+ DBUSLOG_CORE_SIGNAL_BACKLOG,
DBUSLOG_CORE_SIGNAL_DEFAULT_LEVEL,
DBUSLOG_CORE_SIGNAL_CATEGORY_ADDED,
DBUSLOG_CORE_SIGNAL_CATEGORY_REMOVED,
@@ -70,12 +71,14 @@
SIGNAL_CATEGORY_ENABLED,
SIGNAL_CATEGORY_DISABLED,
SIGNAL_CATEGORY_LEVEL,
+ SIGNAL_DEFAULT_LEVEL,
SIGNAL_COUNT
};
#define SIGNAL_CATEGORY_ENABLED_NAME "dbuslog-server-category-enabled"
#define SIGNAL_CATEGORY_DISABLED_NAME "dbuslog-server-category-disabled"
#define SIGNAL_CATEGORY_LEVEL_NAME "dbuslog-server-category-level"
+#define SIGNAL_DEFAULT_LEVEL_NAME "dbuslog-server-default-level"
static guint dbus_log_server_signals[SIGNAL_COUNT] = { 0 };
@@ -85,7 +88,8 @@
DBUSLOG_ACTION_SET_CATEGORY_LEVEL,
DBUSLOG_ACTION_LOG_OPEN,
DBUSLOG_ACTION_CATEGORY_ENABLE,
- DBUSLOG_ACTION_CATEGORY_DISABLE
+ DBUSLOG_ACTION_CATEGORY_DISABLE,
+ DBUSLOG_ACTION_SET_BACKLOG
} DBUSLOG_ACTION;
static const DA_ACTION dbus_log_server_policy_actions[] = {
@@ -94,6 +98,7 @@
{ "LogOpen", DBUSLOG_ACTION_LOG_OPEN, 0 },
{ "CategoryEnable", DBUSLOG_ACTION_CATEGORY_ENABLE, 0 },
{ "CategoryDisable", DBUSLOG_ACTION_CATEGORY_DISABLE, 0 },
+ { "SetBacklog", DBUSLOG_ACTION_SET_BACKLOG, 0 },
{ NULL }
};
@@ -122,13 +127,29 @@
static
void
+dbus_log_server_backlog_changed(
+ DBusLogCore* core,
+ gpointer user_data)
+{
+ DBusLogServer* self = DBUSLOG_SERVER(user_data);
+ DBusLogServerClass* klass = DBUSLOG_SERVER_GET_CLASS(self);
+ if (self->started && klass->emit_backlog_changed) {
+ klass->emit_backlog_changed(self, dbus_log_core_backlog(self->core));
+ }
+}
+
+static
+void
dbus_log_server_default_level_changed(
DBusLogCore* core,
gpointer user_data)
{
DBusLogServer* self = DBUSLOG_SERVER(user_data);
- if (self->started) {
- DBUSLOG_SERVER_GET_CLASS(self)->emit_default_level_changed(self);
+ DBusLogServerClass* klass = DBUSLOG_SERVER_GET_CLASS(self);
+ g_signal_emit(self, dbus_log_server_signals[SIGNAL_DEFAULT_LEVEL], 0,
+ dbus_log_core_default_level(self->core));
+ if (self->started && klass->emit_default_level_changed) {
+ klass->emit_default_level_changed(self);
}
}
@@ -336,6 +357,21 @@
}
}
+int
+dbus_log_server_call_set_backlog(
+ DBusLogServer* self,
+ const char* sender,
+ int backlog)
+{
+ if (!dbus_log_server_access_allowed(self, sender,
+ DBUSLOG_ACTION_SET_BACKLOG)) {
+ return -EACCES;
+ } else {
+ dbus_log_core_set_backlog(self->core, backlog);
+ return 0;
+ }
+}
+
/*==========================================================================*
* API
*==========================================================================*/
@@ -353,11 +389,6 @@
/* Attach to the core signals */
self->core = dbus_log_core_new(0);
- if (klass->emit_default_level_changed) {
- priv->core_signal_id[DBUSLOG_CORE_SIGNAL_DEFAULT_LEVEL] =
- dbus_log_core_add_default_level_handler(self->core,
- dbus_log_server_default_level_changed, self);
- }
if (klass->emit_category_added) {
priv->core_signal_id[DBUSLOG_CORE_SIGNAL_CATEGORY_ADDED] =
dbus_log_core_add_category_added_handler(self->core,
@@ -374,6 +405,12 @@
priv->core_signal_id[DBUSLOG_CORE_SIGNAL_CATEGORY_LEVEL] =
dbus_log_core_add_category_level_handler(self->core,
dbus_log_server_category_level_changed, self);
+ priv->core_signal_id[DBUSLOG_CORE_SIGNAL_DEFAULT_LEVEL] =
+ dbus_log_core_add_default_level_handler(self->core,
+ dbus_log_server_default_level_changed, self);
+ priv->core_signal_id[DBUSLOG_CORE_SIGNAL_BACKLOG] =
+ dbus_log_core_add_backlog_handler(self->core,
+ dbus_log_server_backlog_changed, self);
}
DBusLogServer*
@@ -553,6 +590,16 @@
SIGNAL_CATEGORY_LEVEL_NAME, G_CALLBACK(fn), data) : 0;
}
+gulong
+dbus_log_server_add_default_level_handler(
+ DBusLogServer* self,
+ DBusLogServerLogLevelFunc fn,
+ gpointer data)
+{
+ return (G_LIKELY(self) && G_LIKELY(fn)) ? g_signal_connect(self,
+ SIGNAL_DEFAULT_LEVEL_NAME, G_CALLBACK(fn), data) : 0;
+}
+
void
dbus_log_server_remove_handler(
DBusLogServer* self,
@@ -632,8 +679,7 @@
{
DBusLogServer* self = DBUSLOG_SERVER(object);
DBusLogServerPriv* priv = self->priv;
- dbus_log_core_remove_handlers(self->core, priv->core_signal_id,
- G_N_ELEMENTS(priv->core_signal_id));
+ dbus_log_core_remove_all_handlers(self->core, priv->core_signal_id);
dbus_log_core_unref(self->core);
da_policy_unref(priv->policy);
g_hash_table_destroy(priv->peers);
@@ -666,6 +712,10 @@
g_signal_new(SIGNAL_CATEGORY_LEVEL_NAME, class_type,
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT);
+ dbus_log_server_signals[SIGNAL_DEFAULT_LEVEL] =
+ g_signal_new(SIGNAL_DEFAULT_LEVEL_NAME, class_type,
+ G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 1, G_TYPE_INT);
}
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/dbuslog_server_p.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -38,7 +38,7 @@
#include <gutil_strv.h>
-#define DBUSLOG_INTERFACE_VERSION (1)
+#define DBUSLOG_INTERFACE_VERSION (2)
#define DBUSLOG_LOG_COOKIE (1)
typedef struct dbus_log_server_priv DBusLogServerPriv;
@@ -55,6 +55,7 @@
const char* path;
gboolean started;
gboolean exported;
+ int backlog;
};
typedef struct dbus_log_server_class {
@@ -99,6 +100,10 @@
DBusLogServer* self,
guint id,
guint flags);
+ void
+ (*emit_backlog_changed)(
+ DBusLogServer* self,
+ int backlog);
} DBusLogServerClass;
GType dbus_log_server_get_type(void);
@@ -155,6 +160,12 @@
const char* pattern,
gboolean enable);
+int
+dbus_log_server_call_set_backlog(
+ DBusLogServer* server,
+ const char* peer,
+ int backlog);
+
#endif /* DBUSLOG_SERVER_PRIVATE_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/server/src/gio/dbuslog_server_gio.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -53,6 +53,8 @@
DBUSLOG_METHOD_ENABLE_PATTERN,
DBUSLOG_METHOD_DISABLE,
DBUSLOG_METHOD_DISABLE_PATTERN,
+ DBUSLOG_METHOD_GET_ALL2,
+ DBUSLOG_METHOD_SET_BACKLOG,
DBUSLOG_METHOD_COUNT
};
@@ -208,6 +210,18 @@
static
void
+dbus_log_server_gio_emit_backlog_changed(
+ DBusLogServer* server,
+ int backlog)
+{
+ DBusLogServerGio* self = DBUSLOG_SERVER_GIO(server);
+ if (self->iface) {
+ org_nemomobile_logger_emit_backlog_changed(self->iface, backlog);
+ }
+}
+
+static
+void
dbus_log_server_bus_acquired(
GDBusConnection* bus,
const char* name,
@@ -293,25 +307,48 @@
}
static
-gboolean
-dbus_log_server_handle_get_all(
- OrgNemomobileLogger* proxy,
- GDBusMethodInvocation* call,
- DBusLogServerGio* self)
+GVariant* /* floating */
+dbus_log_server_get_categories_as_variant(
+ DBusLogCore* core)
{
- DBusLogCore* core = self->server.core;
GPtrArray* cats = dbus_log_core_get_categories(core);
GVariantBuilder vb;
guint i;
g_variant_builder_init(&vb, G_VARIANT_TYPE("a(suui)"));
- for (i=0; i<cats->len; i++) {
+ for (i = 0; i < cats->len; i++) {
DBusLogCategory* cat = g_ptr_array_index(cats, i);
g_variant_builder_add(&vb, "(suui)", cat->name, cat->id, cat->flags,
cat->level);
}
+ return g_variant_builder_end(&vb);
+}
+
+static
+gboolean
+dbus_log_server_handle_get_all(
+ OrgNemomobileLogger* proxy,
+ GDBusMethodInvocation* call,
+ DBusLogServerGio* self)
+{
+ DBusLogCore* core = self->server.core;
org_nemomobile_logger_complete_get_all(proxy, call,
DBUSLOG_INTERFACE_VERSION, dbus_log_core_default_level(core),
- g_variant_builder_end(&vb));
+ dbus_log_server_get_categories_as_variant(core));
+ return TRUE;
+}
+
+static
+gboolean
+dbus_log_server_handle_get_all2(
+ OrgNemomobileLogger* proxy,
+ GDBusMethodInvocation* call,
+ DBusLogServerGio* self)
+{
+ DBusLogCore* core = self->server.core;
+ org_nemomobile_logger_complete_get_all2(proxy, call,
+ DBUSLOG_INTERFACE_VERSION, dbus_log_core_default_level(core),
+ dbus_log_server_get_categories_as_variant(core),
+ dbus_log_core_backlog(core));
return TRUE;
}
@@ -464,6 +501,24 @@
return TRUE;
}
+static
+gboolean
+dbus_log_server_handle_set_backlog(
+ OrgNemomobileLogger* proxy,
+ GDBusMethodInvocation* call,
+ gint backlog,
+ DBusLogServerGio* self)
+{
+ const int err = dbus_log_server_call_set_backlog(&self->server,
+ g_dbus_method_invocation_get_sender(call), backlog);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_set_backlog(proxy, call);
+ }
+ return TRUE;
+}
+
/*==========================================================================*
* API
*==========================================================================*/
@@ -487,6 +542,9 @@
self->iface_method_id[DBUSLOG_METHOD_GET_ALL] =
g_signal_connect(self->iface, "handle-get-all",
G_CALLBACK(dbus_log_server_handle_get_all), self);
+ self->iface_method_id[DBUSLOG_METHOD_GET_ALL] =
+ g_signal_connect(self->iface, "handle-get-all2",
+ G_CALLBACK(dbus_log_server_handle_get_all2), self);
self->iface_method_id[DBUSLOG_METHOD_SET_DEFAULT_LEVEL] =
g_signal_connect(self->iface, "handle-set-default-level",
G_CALLBACK(dbus_log_server_handle_set_default_level), self);
@@ -511,6 +569,9 @@
self->iface_method_id[DBUSLOG_METHOD_DISABLE_PATTERN] =
g_signal_connect(self->iface, "handle-category-disable-pattern",
G_CALLBACK(dbus_log_server_handle_disable_pattern), self);
+ self->iface_method_id[DBUSLOG_METHOD_SET_BACKLOG] =
+ g_signal_connect(self->iface, "handle-set-backlog",
+ G_CALLBACK(dbus_log_server_handle_set_backlog), self);
/* And start watching the requested name */
if (service) {
@@ -586,6 +647,7 @@
klass->emit_category_added = dbus_log_server_gio_emit_category_added;
klass->emit_category_removed = dbus_log_server_gio_emit_category_removed;
klass->emit_category_flags_changed = dbus_log_server_gio_emit_flags_changed;
+ klass->emit_backlog_changed = dbus_log_server_gio_emit_backlog_changed;
G_OBJECT_CLASS(klass)->finalize = dbus_log_server_gio_finalize;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/spec/org.nemomobile.Logger.xml
^
|
@@ -3,10 +3,12 @@
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.nemomobile.Logger">
- <!-- Interface version is 1 -->
<method name="GetInterfaceVersion">
<arg name="version" type="i" direction="out"/>
</method>
+
+ <!-- Interface version 1 -->
+
<!--
Each list entry contains name (s), id(u), flags(u) and level(i)
@@ -72,5 +74,20 @@
<signal name="CategoryRemoved">
<arg name="id" type="u"/>
</signal>
+
+ <!-- Interface version 2 -->
+
+ <method name="GetAll2">
+ <arg name="version" type="i" direction="out"/>
+ <arg name="level" type="i" direction="out"/>
+ <arg name="list" type="a(suui)" direction="out"/>
+ <arg name="backlog" type="i" direction="out"/>
+ </method>
+ <method name="SetBacklog">
+ <arg name="backlog" type="i" direction="in"/>
+ </method>
+ <signal name="BacklogChanged">
+ <arg name="backlog" type="i"/>
+ </signal>
</interface>
</node>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/test/Makefile
^
|
@@ -3,3 +3,8 @@
all:
%:
@$(MAKE) -C test_logger $*
+
+clean:
+ @$(MAKE) -C test_logger $@
+ rm -f coverage/*.gcov
+ rm -fr coverage/results
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/test/test_logger/test_logger.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -83,6 +83,7 @@
GMainLoop* loop;
DBusLogSender* sender;
int default_level_changed;
+ int backlog_changed;
int received;
int received_ok;
int ret;
@@ -106,6 +107,17 @@
static
void
+test_basic_backlog_changed(
+ DBusLogCore* core,
+ gpointer user_data)
+{
+ TestBasic* test = user_data;
+ test->backlog_changed++;
+ GVERBOSE_("%d", dbus_log_core_backlog(core));
+}
+
+static
+void
test_basic_message_received(
DBusLogReceiver* receiver,
DBusLogMessage* msg,
@@ -153,7 +165,7 @@
DBusLogReceiver* receiver;
DBusLogSender* dummy;
DBusLogMessage* dummy_msg = dbus_log_message_new(NULL);
- gulong message_id, closed_id, default_level_id;
+ gulong message_id, closed_id, default_level_id, backlog_id;
guint i;
memset(&test, 0, sizeof(test));
@@ -164,6 +176,9 @@
default_level_id = dbus_log_core_add_default_level_handler(core,
test_basic_default_level_changed, &test);
+ backlog_id = dbus_log_core_add_backlog_handler(core,
+ test_basic_backlog_changed, &test);
+ g_assert(backlog_id);
dummy = dbus_log_core_new_sender(core, "Dummy1");
dbus_log_core_remove_sender(core, dummy);
@@ -225,6 +240,20 @@
dbus_log_core_add_category_removed_handler(core, NULL, NULL);
dbus_log_core_add_category_flags_handler(NULL, NULL, NULL);
dbus_log_core_add_category_flags_handler(core, NULL, NULL);
+
+ g_assert(!dbus_log_core_add_backlog_handler(NULL, NULL, NULL));
+ g_assert(!dbus_log_core_add_backlog_handler(core, NULL, NULL));
+ g_assert(!dbus_log_core_backlog(NULL));
+ g_assert(dbus_log_core_backlog(core));
+ dbus_log_core_set_backlog(NULL, 0);
+ g_assert(!test.backlog_changed);
+ dbus_log_core_set_backlog(core, 1);
+ g_assert(test.backlog_changed == 1);
+ dbus_log_core_set_backlog(core, 1);
+ g_assert(test.backlog_changed == 1);
+ dbus_log_core_set_backlog(core, 2);
+ g_assert(test.backlog_changed == 2);
+
dbus_log_core_remove_handler(NULL, 0);
dbus_log_core_remove_handler(core, 0);
dbus_log_message_ref(NULL);
@@ -281,6 +310,7 @@
dbus_log_receiver_unref(receiver);
dbus_log_sender_unref(test.sender);
dbus_log_core_remove_handler(core, default_level_id);
+ dbus_log_core_remove_handler(core, backlog_id);
dbus_log_core_unref(core);
dbus_log_message_unref(dummy_msg);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/tools/dbuslog-client/Makefile
^
|
@@ -1,6 +1,6 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: clean all debug release
+.PHONY: clean all debug release install
.PHONY: common_debug common_release
.PHONY: client_debug client_release
@@ -164,3 +164,17 @@
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif
+
+#
+# Install
+#
+
+INSTALL = install
+
+INSTALL_BIN_DIR = $(DESTDIR)/usr/bin
+
+install: release $(INSTALL_BIN_DIR)
+ $(INSTALL) -m 755 $(RELEASE_EXE) $(INSTALL_BIN_DIR)
+
+$(INSTALL_BIN_DIR):
+ $(INSTALL) -d $@
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libdbuslog/tools/dbuslog-client/main.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Jolla Ltd.
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -62,6 +62,7 @@
gboolean datetime;
gboolean timestamp;
gboolean print_log_level;
+ gboolean print_backlog;
char* out_filename;
FILE* out_file;
gulong event_id[APP_N_EVENTS];
@@ -254,6 +255,23 @@
static
DBusLogClientCall*
+app_action_set_backlog(
+ AppAction* action)
+{
+ AppActionInt* int_action = G_CAST(action,AppActionInt,action);
+ DBusLogClient* client = action->app->client;
+ if (client->api_version > 1) {
+ GDEBUG("Settings backlog to %d", int_action->value);
+ return dbus_log_client_set_backlog(action->app->client,
+ int_action->value, app_action_call_done, action);
+ } else {
+ GERR("Backlog API is not supported by the remote");
+ return NULL;
+ }
+}
+
+static
+DBusLogClientCall*
app_action_enable_all(
AppAction* action)
{
@@ -348,10 +366,19 @@
client_connected(
App* app)
{
+ DBusLogClient* client = app->client;
GDEBUG("Connected!");
if (app->print_log_level) {
app->print_log_level = FALSE;
- printf("%d\n", app->client->default_level);
+ printf("%d\n", client->default_level);
+ }
+ if (app->print_backlog) {
+ app->print_backlog = FALSE;
+ if (client->api_version > 1) {
+ printf("%d\n", client->backlog);
+ } else {
+ GERR("Backlog API is not supported by the remote");
+ }
}
app_next_action(app);
}
@@ -652,6 +679,32 @@
static
gboolean
+app_option_backlog(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ App* app = data;
+ if (value) {
+ const int level = atoi(value);
+ if (level > 0) {
+ app_add_action(app, app_action_int_new(app,
+ app_action_set_backlog, level));
+ return TRUE;
+ } else {
+ g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "Invalid backlog \'%s\'", value);
+ return FALSE;
+ }
+ } else {
+ app->print_backlog = TRUE;
+ return TRUE;
+ }
+}
+
+static
+gboolean
app_init(
App* app,
int argc,
@@ -685,6 +738,10 @@
app_option_log_level, "Show the current log level", NULL },
{ "log-level", 'l', 0, G_OPTION_ARG_CALLBACK, app_option_log_level,
"Set the log level (1..8)", "LEVEL" },
+ { "print-backlog", 'B', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ app_option_backlog, "Show current backlog", NULL },
+ { "backlog", 'b', 0, G_OPTION_ARG_CALLBACK, app_option_backlog,
+ "Set the backlog", "COUNT" },
{ "all", 'a', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
app_option_enable_all, "Enable all log categories", NULL },
{ "none", 'n', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
@@ -721,7 +778,7 @@
if (list) {
app_add_action(app, app_action_new(app, app_action_list));
}
- if (!app->actions && !app->print_log_level) {
+ if (!app->actions && !app->print_log_level && !app->print_backlog) {
/* Default action */
app->follow = TRUE;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/Makefile
^
|
@@ -20,7 +20,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 29
+VERSION_RELEASE = 35
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/debian/changelog
^
|
@@ -1,3 +1,47 @@
+libglibutil (1.0.35) unstable; urgency=low
+
+ * Added gutil_strv_last() function
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 13 Feb 2019 19:56:31 +0300
+
+libglibutil (1.0.34) unstable; urgency=low
+
+ * Added a few more GUtilIdlePool functions:
+
+ gutil_idle_pool_destroy
+ gutil_idle_pool_add_bytes
+ gutil_idle_pool_add_bytes_ref
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 07 Nov 2018 17:57:52 +0300
+
+libglibutil (1.0.33) unstable; urgency=low
+
+ * Added GLOG_FLAG_DISABLE flag
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 03 Nov 2018 11:47:25 +0300
+
+libglibutil (1.0.32) unstable; urgency=low
+
+ * Added gutil_idle_pool_add_strv function
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 14 Oct 2018 00:47:01 +0300
+
+libglibutil (1.0.31) unstable; urgency=low
+
+ * Added GUtilData type and functions to work with it:
+
+ gutil_data_equal
+ gutil_data_from_string
+ gutil_data_from_bytes
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 13 Oct 2018 13:17:45 +0300
+
+libglibutil (1.0.30) unstable; urgency=low
+
+ * Added gutil_parse_int function
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 20 Jul 2018 00:06:40 +0300
+
libglibutil (1.0.29) unstable; urgency=low
* Added gutil_hexdump function
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/include/gutil_idlepool.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -48,6 +48,7 @@
* gutil_idle_pool_add_object()
* gutil_idle_pool_add_variant()
* gutil_idle_pool_add_ptr_array()
+ * gutil_idle_pool_add_bytes()
*
* The following functions, however, do add the reference and hold it
* until the pool is drained:
@@ -55,6 +56,7 @@
* gutil_idle_pool_add_object_ref()
* gutil_idle_pool_add_variant_ref()
* gutil_idle_pool_add_ptr_array_ref()
+ * gutil_idle_pool_add_bytes_ref()
*/
GUtilIdlePool*
@@ -73,6 +75,10 @@
GUtilIdlePool* pool);
void
+gutil_idle_pool_destroy(
+ GUtilIdlePool* pool); /* Since 1.0.34 */
+
+void
gutil_idle_pool_drain(
GUtilIdlePool* pool);
@@ -83,6 +89,11 @@
GDestroyNotify destroy);
void
+gutil_idle_pool_add_strv(
+ GUtilIdlePool* pool,
+ char** strv); /* Since 1.0.32 */
+
+void
gutil_idle_pool_add_object(
GUtilIdlePool* pool,
gpointer object);
@@ -98,6 +109,11 @@
GPtrArray* array);
void
+gutil_idle_pool_add_bytes(
+ GUtilIdlePool* pool,
+ GBytes* bytes); /* Since 1.0.34 */
+
+void
gutil_idle_pool_add_object_ref(
GUtilIdlePool* pool,
gpointer object);
@@ -112,6 +128,11 @@
GUtilIdlePool* pool,
GPtrArray* array);
+void
+gutil_idle_pool_add_bytes_ref(
+ GUtilIdlePool* pool,
+ GBytes* bytes); /* Since 1.0.34 */
+
G_END_DECLS
#endif /* GUTIL_IDLEPOOL_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/include/gutil_log.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2018 Jolla Ltd.
+ * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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 the 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
@@ -87,6 +87,7 @@
};
#define GLOG_FLAG_HIDE_NAME (0x01) /* Don't print the module name */
+#define GLOG_FLAG_DISABLE (0x02) /* Don't print this log */
/* Command line parsing helper. Option format is [module]:level
* where level can be either a number or log level name ("none", err etc.) */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/include/gutil_misc.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2019 Jolla Ltd.
+ * Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -40,7 +40,7 @@
void
gutil_disconnect_handlers(
gpointer instance,
- gulong *ids,
+ gulong* ids,
int count);
void*
@@ -54,6 +54,7 @@
const char* str,
gssize len);
+/* since 1.0.29 */
#define GUTIL_HEXDUMP_BUFSIZE (70)
#define GUTIL_HEXDUMP_MAXBYTES (16)
@@ -61,7 +62,30 @@
gutil_hexdump(
char* buf,
const void* data,
- guint len); /* since 1.0.29 */
+ guint len);
+
+/* since 1.0.30 */
+gboolean
+gutil_parse_int(
+ const char* str,
+ int base,
+ int* value);
+
+/* since 1.0.31 */
+gboolean
+gutil_data_equal(
+ const GUtilData* data1,
+ const GUtilData* data2);
+
+const GUtilData*
+gutil_data_from_string(
+ GUtilData* data,
+ const char* str);
+
+const GUtilData*
+gutil_data_from_bytes(
+ GUtilData* data,
+ GBytes* bytes);
G_END_DECLS
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/include/gutil_strv.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2019 Jolla Ltd.
+ * Copyright (C) 2014-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -53,6 +53,13 @@
guint i);
/**
+ * Returns the last string in the array, NULL if there's nothing there.
+ */
+const char*
+gutil_strv_last(
+ const GStrV* sv); /* Since 1.0.35 */
+
+/**
* Returns index of the specified string in the string array,
* or -1 if the string is not found.
*/
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/include/gutil_types.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -49,6 +49,11 @@
typedef struct gutil_ring GUtilRing;
typedef struct gutil_time_notify GUtilTimeNotify;
+typedef struct gutil_data {
+ const guint8* bytes;
+ gsize size;
+} GUtilData;
+
#define GLOG_MODULE_DECL(m) extern GLogModule m;
typedef struct glog_module GLogModule;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/rpm/libglibutil.spec
^
|
@@ -1,5 +1,5 @@
Name: libglibutil
-Version: 1.0.29
+Version: 1.0.35
Release: 0
Summary: Library of glib utilities
Group: Development/Libraries
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/src/gutil_idlepool.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -55,7 +55,7 @@
gutil_idle_pool_new()
{
GUtilIdlePool* self = g_slice_new0(GUtilIdlePool);
- self->ref_count = 1;
+ g_atomic_int_set(&self->ref_count, 1);
return self;
}
@@ -109,6 +109,14 @@
}
void
+gutil_idle_pool_destroy(
+ GUtilIdlePool* self) /* Since 1.0.34 */
+{
+ gutil_idle_pool_drain(self);
+ gutil_idle_pool_unref(self);
+}
+
+void
gutil_idle_pool_drain(
GUtilIdlePool* self)
{
@@ -169,6 +177,16 @@
}
void
+gutil_idle_pool_add_strv(
+ GUtilIdlePool* self,
+ char** strv) /* Since 1.0.32 */
+{
+ if (G_LIKELY(strv)) {
+ gutil_idle_pool_add(self, strv, (GDestroyNotify) g_strfreev);
+ }
+}
+
+void
gutil_idle_pool_add_object(
GUtilIdlePool* self,
gpointer object)
@@ -199,6 +217,16 @@
}
void
+gutil_idle_pool_add_bytes(
+ GUtilIdlePool* self,
+ GBytes* bytes) /* Since 1.0.34 */
+{
+ if (G_LIKELY(bytes)) {
+ gutil_idle_pool_add(self, bytes, (GDestroyNotify)g_bytes_unref);
+ }
+}
+
+void
gutil_idle_pool_add_object_ref(
GUtilIdlePool* self,
gpointer object)
@@ -228,6 +256,16 @@
}
}
+void
+gutil_idle_pool_add_bytes_ref(
+ GUtilIdlePool* self,
+ GBytes* bytes) /* Since 1.0.34 */
+{
+ if (G_LIKELY(self) && G_LIKELY(bytes)) {
+ gutil_idle_pool_add_bytes(self, g_bytes_ref(bytes));
+ }
+}
+
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/src/gutil_log.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2018 Jolla Ltd.
+ * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -302,17 +302,20 @@
const char* format,
va_list va)
{
- if (check && check->level == GLOG_LEVEL_INHERIT && check->parent) {
- gutil_logv_r(module, check->parent, level, format, va);
- } else {
- const int max_level = (check && check->level != GLOG_LEVEL_INHERIT) ?
- check->level : gutil_log_default.level;
- if ((level > GLOG_LEVEL_NONE && level <= max_level) ||
- (level == GLOG_LEVEL_ALWAYS)) {
- GLogProc2 log = gutil_log_func2;
- if (G_LIKELY(log)) {
- if (!module) module = &gutil_log_default;
- log(module, level, format, va);
+ if (!check || !(check->flags & GLOG_FLAG_DISABLE)) {
+ if (check && check->level == GLOG_LEVEL_INHERIT && check->parent) {
+ gutil_logv_r(module, check->parent, level, format, va);
+ } else {
+ const int max_level =
+ (check && check->level != GLOG_LEVEL_INHERIT) ?
+ check->level : gutil_log_default.level;
+ if ((level > GLOG_LEVEL_NONE && level <= max_level) ||
+ (level == GLOG_LEVEL_ALWAYS)) {
+ GLogProc2 log = gutil_log_func2;
+ if (G_LIKELY(log)) {
+ if (!module) module = &gutil_log_default;
+ log(module, level, format, va);
+ }
}
}
}
@@ -363,7 +366,9 @@
const GLogModule* module,
int level)
{
- if (module->level == GLOG_LEVEL_INHERIT && module->parent) {
+ if (module->flags & GLOG_FLAG_DISABLE) {
+ return FALSE;
+ } else if (module->level == GLOG_LEVEL_INHERIT && module->parent) {
return gutil_log_enabled_r(module->parent, level);
} else {
const int max_level = (module->level == GLOG_LEVEL_INHERIT) ?
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/src/gutil_misc.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -35,6 +35,8 @@
#include <glib-object.h>
#include <ctype.h>
+#include <limits.h>
+#include <errno.h>
void
gutil_disconnect_handlers(
@@ -151,6 +153,81 @@
return bytes_dumped;
}
+/* Since 1.0.30 */
+gboolean
+gutil_parse_int(
+ const char* str,
+ int base,
+ int* value)
+{
+ gboolean ok = FALSE;
+
+ if (str && str[0]) {
+ char* str2 = g_strstrip(g_strdup(str));
+ char* end = str2;
+ gint64 l;
+
+ errno = 0;
+ l = g_ascii_strtoll(str2, &end, base);
+ ok = !*end && errno != ERANGE && l >= INT_MIN && l <= INT_MAX;
+ if (ok && value) {
+ *value = (int)l;
+ }
+ g_free(str2);
+ }
+ return ok;
+}
+
+/* since 1.0.31 */
+gboolean
+gutil_data_equal(
+ const GUtilData* data1,
+ const GUtilData* data2)
+{
+ if (data1 == data2) {
+ return TRUE;
+ } else if (!data1 || !data2) {
+ return FALSE;
+ } else if (data1->size == data2->size) {
+ return !memcmp(data1->bytes, data2->bytes, data1->size);
+ } else {
+ return FALSE;
+ }
+}
+
+const GUtilData*
+gutil_data_from_string(
+ GUtilData* data,
+ const char* str)
+{
+ if (data) {
+ if (str) {
+ data->bytes = (const void*)str;
+ data->size = strlen(str);
+ } else {
+ data->bytes = NULL;
+ data->size = 0;
+ }
+ }
+ return data;
+}
+
+const GUtilData*
+gutil_data_from_bytes(
+ GUtilData* data,
+ GBytes* bytes)
+{
+ if (data) {
+ if (bytes) {
+ data->bytes = g_bytes_get_data(bytes, &data->size);
+ } else {
+ data->bytes = NULL;
+ data->size = 0;
+ }
+ }
+ return data;
+}
+
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/src/gutil_strv.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2019 Jolla Ltd.
+ * Copyright (C) 2014-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -68,6 +68,21 @@
}
return NULL;
}
+
+/**
+ * Returns the last string in the array, NULL if there's nothing there.
+ */
+const char*
+gutil_strv_last(
+ const GStrV* sv) /* Since 1.0.35 */
+{
+ if (G_LIKELY(sv) && G_LIKELY(sv[0])) {
+ guint k = 0;
+ while (sv[k + 1]) k++;
+ return sv[k];
+ }
+ return NULL;
+}
/**
* Returns index of the specified string in the string array,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/test/common/test_common.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -55,6 +55,10 @@
int argc,
char* argv[]);
+/* Macros */
+
+#define TEST_INIT_DATA(a,b) ((a).bytes = (void*)(b), (a).size = sizeof(b))
+
#endif /* TEST_COMMON_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/test/test_idlepool/test_idlepool.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -33,6 +33,7 @@
#include "test_common.h"
#include "gutil_idlepool.h"
+#include "gutil_strv.h"
#include "gutil_log.h"
#define TEST_TIMEOUT (10) /* seconds */
@@ -57,6 +58,44 @@
}
/*==========================================================================*
+ * Null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ GUtilIdlePool* pool = gutil_idle_pool_new();
+
+ /* These have no effect, just testing NULL-telerance */
+ gutil_idle_pool_add_strv(NULL, NULL);
+ gutil_idle_pool_add_strv(pool, NULL);
+ gutil_idle_pool_add_ptr_array(NULL, NULL);
+ gutil_idle_pool_add_ptr_array(pool, NULL);
+ gutil_idle_pool_add_ptr_array_ref(NULL, NULL);
+ gutil_idle_pool_add_ptr_array_ref(pool, NULL);
+ gutil_idle_pool_add_variant(NULL, NULL);
+ gutil_idle_pool_add_variant(pool, NULL);
+ gutil_idle_pool_add_variant_ref(NULL, NULL);
+ gutil_idle_pool_add_variant_ref(pool, NULL);
+ gutil_idle_pool_add_object(NULL, NULL);
+ gutil_idle_pool_add_object(pool, NULL);
+ gutil_idle_pool_add_object_ref(NULL, NULL);
+ gutil_idle_pool_add_object_ref(pool, NULL);
+ gutil_idle_pool_add_bytes(NULL, NULL);
+ gutil_idle_pool_add_bytes(pool, NULL);
+ gutil_idle_pool_add_bytes_ref(NULL, NULL);
+ gutil_idle_pool_add_bytes_ref(pool, NULL);
+ gutil_idle_pool_add(NULL, NULL, NULL);
+ gutil_idle_pool_add(pool, NULL, NULL);
+ gutil_idle_pool_ref(NULL);
+ gutil_idle_pool_unref(NULL);
+ gutil_idle_pool_drain(NULL);
+ gutil_idle_pool_unref(pool);
+}
+
+/*==========================================================================*
* Basic
*==========================================================================*/
@@ -114,6 +153,8 @@
GVariant* variant = g_variant_take_ref(g_variant_new_int32(1));
GObject* object = g_object_new(TEST_OBJECT_TYPE, NULL);
GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+ GStrV* strv = gutil_strv_add(NULL, "foo");
+ GBytes* bytes = g_bytes_new("bar", 3);
TestBasic test;
memset(&test, 0, sizeof(test));
@@ -123,26 +164,8 @@
g_timeout_add_seconds(TEST_TIMEOUT, test_timeout, loop);
}
- /* These have no effect, just testing NULL-telerance */
gutil_idle_pool_unref(gutil_idle_pool_new());
- gutil_idle_pool_add_ptr_array(NULL, array);
- gutil_idle_pool_add_ptr_array(test.pool, NULL);
- gutil_idle_pool_add_ptr_array_ref(NULL, array);
- gutil_idle_pool_add_ptr_array_ref(test.pool, NULL);
- gutil_idle_pool_add_variant(NULL, variant);
- gutil_idle_pool_add_variant(test.pool, NULL);
- gutil_idle_pool_add_variant_ref(NULL, variant);
- gutil_idle_pool_add_variant_ref(test.pool, NULL);
- gutil_idle_pool_add_object(NULL, object);
- gutil_idle_pool_add_object(test.pool, NULL);
- gutil_idle_pool_add_object_ref(NULL, object);
- gutil_idle_pool_add_object_ref(test.pool, NULL);
- gutil_idle_pool_add(NULL, NULL, test_basic_unref_pool);
- gutil_idle_pool_add(test.pool, NULL, NULL);
- gutil_idle_pool_ref(NULL);
- gutil_idle_pool_unref(NULL);
- gutil_idle_pool_drain(NULL);
-
+ gutil_idle_pool_add_strv(test.pool, strv);
g_ptr_array_add(array, &test);
gutil_idle_pool_add_ptr_array_ref(test.pool, array);
g_ptr_array_unref(array);
@@ -150,12 +173,14 @@
g_variant_unref(variant);
gutil_idle_pool_add_object_ref(test.pool, object);
g_object_unref(object);
+ gutil_idle_pool_add_bytes_ref(test.pool, bytes);
+ g_bytes_unref(bytes);
gutil_idle_pool_ref(test.pool);
gutil_idle_pool_add(test.pool, &test, test_basic_unref_pool);
gutil_idle_pool_add(test.pool, loop, test_done);
g_main_loop_run(loop);
gutil_idle_pool_add(test.pool, &test, test_basic_add_during_drain);
- gutil_idle_pool_unref(test.pool);
+ gutil_idle_pool_destroy(test.pool);
g_assert(test.ok);
g_assert(!test_object_count);
@@ -196,7 +221,7 @@
* Common
*==========================================================================*/
-#define TEST_PREFIX "/idlepool/"
+#define TEST_(test) "/idlepool/" test
int main(int argc, char* argv[])
{
@@ -204,8 +229,9 @@
g_type_init();
G_GNUC_END_IGNORE_DEPRECATIONS;
g_test_init(&argc, &argv, NULL);
- g_test_add_func(TEST_PREFIX "basic", test_basic);
- g_test_add_func(TEST_PREFIX "shared", test_shared);
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("basic"), test_basic);
+ g_test_add_func(TEST_("shared"), test_shared);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/test/test_log/test_log.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2018 Jolla Ltd.
+ * Copyright (C) 2017-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -92,6 +92,12 @@
g_assert(test_log_basic_buf->len);
g_string_set_size(test_log_basic_buf, 0);
+ /* Test GLOG_FLAG_DISABLE */
+ module.flags |= GLOG_FLAG_DISABLE;
+ gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
+ g_assert(!test_log_basic_buf->len);
+ module.flags &= ~GLOG_FLAG_DISABLE;
+
/* Without log functions these calls have no effect */
gutil_log_func = NULL;
gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
@@ -126,6 +132,9 @@
gutil_log_default.level = GLOG_LEVEL_INFO;
g_assert(gutil_log_enabled(&gutil_log_default, GLOG_LEVEL_ALWAYS));
g_assert(gutil_log_enabled(&gutil_log_default, GLOG_LEVEL_INFO));
+ gutil_log_default.flags |= GLOG_FLAG_DISABLE;
+ g_assert(!gutil_log_enabled(&gutil_log_default, GLOG_LEVEL_INFO));
+ gutil_log_default.flags &= ~GLOG_FLAG_DISABLE;
g_assert(!gutil_log_enabled(&gutil_log_default, GLOG_LEVEL_DEBUG));
/* It makes no sense to have default as INHERIT so it's treated as NONE */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/test/test_misc/test_misc.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2018 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -158,6 +158,115 @@
}
/*==========================================================================*
+ * ParseInt
+ *==========================================================================*/
+
+static
+void
+test_parse_int(
+ void)
+{
+ int value;
+
+ g_assert(!gutil_parse_int(NULL, 0, NULL));
+ g_assert(!gutil_parse_int("", 0, NULL));
+ g_assert(!gutil_parse_int("garbage", 0, NULL));
+ g_assert(!gutil_parse_int("0 trailing garbage", 0, NULL));
+ g_assert(gutil_parse_int("0", 0, NULL));
+ g_assert(gutil_parse_int("0", 0, &value));
+ g_assert(value == 0);
+ g_assert(!gutil_parse_int("0x10000000000000000", 0, &value));
+ g_assert(!gutil_parse_int("-2147483649", 0, &value));
+ g_assert(!gutil_parse_int("4294967295", 0, &value));
+ g_assert(gutil_parse_int(" 0x7fffffff ", 0, &value));
+ g_assert(value == 0x7fffffff);
+ g_assert(gutil_parse_int(" 7fffffff ", 16, &value));
+ g_assert(value == 0x7fffffff);
+ g_assert(!gutil_parse_int("0xffffffff", 0, &value));
+}
+
+/*==========================================================================*
+ * DataEqual
+ *==========================================================================*/
+
+static
+void
+test_data_equal(
+ void)
+{
+ static const guint8 val_123[] = { '1', '2', '3' };
+ static const guint8 val_1234[] = { '1', '2', '3', '4' };
+ static const guint8 val_321[] = { '3', '2', '1' };
+
+ GUtilData data_123, data_123a, data_1234, data_321;
+
+ TEST_INIT_DATA(data_123, val_123);
+ TEST_INIT_DATA(data_123a, val_123);
+ TEST_INIT_DATA(data_1234, val_1234);
+ TEST_INIT_DATA(data_321, val_321);
+
+ g_assert(gutil_data_equal(NULL, NULL));
+ g_assert(gutil_data_equal(&data_123, &data_123));
+ g_assert(gutil_data_equal(&data_123, &data_123a));
+ g_assert(!gutil_data_equal(&data_123, &data_1234));
+ g_assert(!gutil_data_equal(&data_123, &data_321));
+ g_assert(!gutil_data_equal(&data_123, NULL));
+ g_assert(!gutil_data_equal(NULL, &data_123));
+}
+
+/*==========================================================================*
+ * DataFromBytes
+ *==========================================================================*/
+
+static
+void
+test_data_from_bytes(
+ void)
+{
+ static const guint8 val_123[] = { '1', '2', '3' };
+ GBytes* bytes_123 = g_bytes_new_static(val_123, sizeof(val_123));
+ GUtilData data_123, data;
+
+ TEST_INIT_DATA(data_123, val_123);
+ TEST_INIT_DATA(data, val_123);
+
+ g_assert(!gutil_data_from_bytes(NULL, NULL));
+
+ g_assert(gutil_data_from_bytes(&data, NULL) == &data);
+ g_assert(!data.bytes);
+ g_assert(!data.size);
+
+ g_assert(gutil_data_from_bytes(&data, bytes_123) == &data);
+ g_assert(gutil_data_equal(&data_123, &data));
+ g_bytes_unref(bytes_123);
+}
+
+/*==========================================================================*
+ * DataFromString
+ *==========================================================================*/
+
+static
+void
+test_data_from_string(
+ void)
+{
+ static const guint8 val_123[] = { '1', '2', '3' };
+ GUtilData data_123, data;
+
+ TEST_INIT_DATA(data_123, val_123);
+ TEST_INIT_DATA(data, val_123);
+
+ g_assert(!gutil_data_from_string(NULL, NULL));
+
+ g_assert(gutil_data_from_string(&data, NULL) == &data);
+ g_assert(!data.bytes);
+ g_assert(!data.size);
+
+ g_assert(gutil_data_from_string(&data, "123") == &data);
+ g_assert(gutil_data_equal(&data_123, &data));
+}
+
+/*==========================================================================*
* Common
*==========================================================================*/
@@ -177,6 +286,10 @@
g_test_add_func(TEST_PREFIX "disconnect", test_disconnect);
g_test_add_func(TEST_PREFIX "hex2bin", test_hex2bin);
g_test_add_func(TEST_PREFIX "hexdump", test_hexdump);
+ g_test_add_func(TEST_PREFIX "parse_int", test_parse_int);
+ g_test_add_func(TEST_PREFIX "data_equal", test_data_equal);
+ g_test_add_func(TEST_PREFIX "data_from_bytes", test_data_from_bytes);
+ g_test_add_func(TEST_PREFIX "data_from_string", test_data_from_string);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/libglibutil/test/test_strv/test_strv.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -13,9 +13,9 @@
* 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.
+ * 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
@@ -61,6 +61,29 @@
}
/*==========================================================================*
+ * Last
+ *==========================================================================*/
+
+static
+void
+test_last(
+ void)
+{
+ char** empty = g_new0(char*, 1);
+ char** a = g_strsplit("a", ",", 0);
+ char** ab = g_strsplit("a,b", ",", 0);
+
+ g_assert(!gutil_strv_last(NULL));
+ g_assert(!gutil_strv_last(empty));
+ g_assert(!g_strcmp0(gutil_strv_last(a), "a"));
+ g_assert(!g_strcmp0(gutil_strv_last(ab), "b"));
+
+ g_strfreev(empty);
+ g_strfreev(a);
+ g_strfreev(ab);
+}
+
+/*==========================================================================*
* Equal
*==========================================================================*/
@@ -190,6 +213,7 @@
{
g_test_init(&argc, &argv, NULL);
g_test_add_func(TEST_PREFIX "basic", test_basic);
+ g_test_add_func(TEST_PREFIX "last", test_last);
g_test_add_func(TEST_PREFIX "equal", test_equal);
g_test_add_func(TEST_PREFIX "find", test_find);
g_test_add_func(TEST_PREFIX "remove", test_remove);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/mmsengine.cpp
^
|
@@ -1,38 +1,40 @@
/*
- Copyright (C) 2014-2018 Jolla Ltd.
- Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.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:
-
- * 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 the 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.
-
- 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.
-*/
+ * Copyright (C) 2014-2019 Jolla Ltd.
+ * Copyright (C) 2014-2019 Slava Monich <slava.monich@jolla.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 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 "mmsengine.h"
#include "mmsenginelog.h"
+#include "dbusaccess_peer.h"
+
#include "HarbourDebug.h"
#include <QDir>
@@ -44,6 +46,7 @@
#include <sys/prctl.h>
#define MMS_ENGINE "/usr/sbin/mms-engine"
+#define MMS_ENGINE_NAME "org.nemomobile.MmsEngine"
#define MMS_ENGINE_RESTART_DELAY (1000)
#define MMS_ENGINE_MAX_RESTARTS (10)
@@ -85,17 +88,11 @@
void MMSEngine::killEngine()
{
- QDir proc("/proc");
- QStringList entries = proc.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
- foreach (QString entry, entries) {
- int pid = entry.toInt();
- if (pid) {
- QString exe = QFile::symLinkTarget(proc.filePath(entry).append("/exe"));
- if (!exe.isEmpty() && QFile::exists(exe) && exe == MMS_ENGINE) {
- HDEBUG("MMS engine already running, pid" << pid);
- kill(pid, SIGTERM);
- break;
- }
+ DAPeer* peer = da_peer_get(DA_BUS_SYSTEM, MMS_ENGINE_NAME);
+ if (peer) {
+ HDEBUG("MMS engine already running, pid" << peer->pid);
+ if (kill(peer->pid, SIGTERM) < 0) {
+ HWARN("Failed to kill MMS engine:" << strerror(errno));
}
}
}
@@ -115,7 +112,7 @@
iPid = fork();
if (iPid > 0) {
// Parent
- HDEBUG("Stared MMS engine, pid" << iPid);
+ HDEBUG("Started MMS engine, pid" << iPid);
return startLogThread(iPipe = pty);
} else if (iPid == 0) {
// Child
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-mmslog-1.0.16.tar.bz2/src/org.ofono.Manager.xml
^
|
@@ -8,6 +8,7 @@
<arg name="modems" type="a(oa{sv})" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="OfonoObjectPathPropertiesList"/>
</method>
+ <!--
<signal name="ModemAdded">
<arg name="path" type="o"/>
<arg name="properties" type="a{sv}"/>
@@ -16,5 +17,6 @@
<signal name="ModemRemoved">
<arg name="path" type="o"/>
</signal>
+ -->
</interface>
</node>
|