[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">http://git.monich.net/git/harbour-logger.git</param>
<param name="branch">connman</param>
- <param name="revision">1bbb183</param>
+ <param name="revision">699a084</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/.gitignore
^
|
@@ -1,2 +1,2 @@
-harbour-lib.pro.user
+harbour-lib.pro.user*
build
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/LICENSE
^
|
@@ -0,0 +1,30 @@
+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:
+
+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
+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.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/harbour-lib.pro
^
|
@@ -2,12 +2,12 @@
CONFIG += static
TARGET = harbour-lib
QT += dbus
-QT -= gui
+QT-= gui
VERSION = 1.0
greaterThan(QT_MAJOR_VERSION, 4) {
-QT += qml
+QT += qml quick
} else {
QT += declarative
}
@@ -19,27 +19,48 @@
}
SOURCES += \
+ src/HarbourDisplayBlanking.cpp \
src/HarbourJson.cpp \
src/HarbourLib.cpp \
+ src/HarbourMce.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSystemState.cpp \
+ src/HarbourTask.cpp \
+ src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
src/HarbourTransferMethodsModel.cpp
+greaterThan(QT_MAJOR_VERSION, 4) {
+SOURCES += \
+ src/HarbourImageProvider.cpp \
+ src/HarbourPluginLoader.cpp
+}
+
INCLUDEPATH += include
PUBLIC_HEADERS += \
include/HarbourDebug.h \
+ include/HarbourDisplayBlanking.h \
include/HarbourJson.h \
include/HarbourLib.h \
include/HarbourSigChildHandler.h \
include/HarbourSystemState.h \
+ include/HarbourTask.h \
+ include/HarbourTemporaryFile.h \
include/HarbourTransferMethodInfo.h \
include/HarbourTransferMethodsModel.h
+greaterThan(QT_MAJOR_VERSION, 4) {
+PUBLIC_HEADERS += \
+ include/HarbourImageProvider.h \
+ include/HarbourPluginLoader.h
+}
+
HEADERS += \
- $$PUBLIC_HEADERS
+ $$PUBLIC_HEADERS \
+ src/HarbourMce.h
OTHER_FILES += \
+ LICENSE \
rpm/harbour-lib-devel.spec
headers.path = $$INSTALL_ROOT$$PREFIX/include/$$TARGET
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourDisplayBlanking.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ *
+ * 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 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
+ * 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_DISPLAY_BLANKING_H
+#define HARBOUR_DISPLAY_BLANKING_H
+
+#include <QObject>
+#include <QString>
+#include <QSharedPointer>
+
+class HarbourDisplayBlanking: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool paused READ paused NOTIFY pausedChanged)
+ Q_PROPERTY(bool pauseAllowed READ pauseAllowed NOTIFY pauseAllowedChanged)
+ Q_PROPERTY(bool pauseRequested READ pauseRequested WRITE setPauseRequested NOTIFY pauseRequestedChanged)
+
+public:
+ explicit HarbourDisplayBlanking(QObject* aParent = NULL);
+ ~HarbourDisplayBlanking();
+
+ static QSharedPointer<HarbourDisplayBlanking> sharedInstance();
+
+ bool paused() const;
+ bool pauseAllowed() const;
+ bool pauseRequested() const;
+ void setPauseRequested(bool value);
+
+Q_SIGNALS:
+ void pausedChanged();
+ void pauseAllowedChanged();
+ void pauseRequestedChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_DISPLAY_BLANKING_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourImageProvider.h
^
|
@@ -0,0 +1,50 @@
+/*
+ * 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 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
+ * 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_PROVIDER_H
+#define HARBOUR_IMAGE_PROVIDER_H
+
+#include <QQuickImageProvider>
+
+class HarbourImageProvider : public QQuickImageProvider
+{
+public:
+ class TextureFactory;
+ class Theme;
+
+ HarbourImageProvider();
+ QQuickTextureFactory* requestTexture(const QString& aId, QSize* aSize,
+ const QSize &requestedSize) Q_DECL_OVERRIDE;
+};
+
+#endif // HARBOUR_IMAGE_PROVIDER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourPluginLoader.h
^
|
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Copyright (C) 2017 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 HARBOUR_PLUGIN_LOADER_H
+#define HARBOUR_PLUGIN_LOADER_H
+
+#include <QString>
+
+class QQmlEngine;
+class QPluginLoader;
+
+//
+// This object has its most useful methods protected because it's supposed
+// to be subclassed line this:
+//
+// class DocGalleryPlugin : public HarbourPluginLoader {
+// public:
+// DocGalleryPlugin(QQmlEngine* engine);
+// void registerTypes(const char* module, int v1, int v2);
+// };
+//
+// DocGalleryPlugin::DocGalleryPlugin(QQmlEngine* engine) :
+// HarbourPluginLoader(engine, "QtDocGallery", 5, 0)
+// {
+// }
+//
+// void DocGalleryPlugin::registerTypes(const char* module, int v1, int v2)
+// {
+// reRegisterType("DocumentGallery", module, v1, v2);
+// reRegisterType("DocumentGalleryModel", module, v1, v2);
+// reRegisterType("GalleryStartsWithFilter", module, v1, v2);
+// }
+//
+// And it's generally a hack, it's best to avoid using this class at all.
+//
+
+class HarbourPluginLoader
+{
+public:
+ bool isValid() const;
+
+protected:
+ HarbourPluginLoader(QQmlEngine* aEngine, QString aModule,
+ int aMajor, int aMinor);
+ ~HarbourPluginLoader();
+
+ void reRegisterType(const char* aOrigQmlName, const char* aNewQmlName,
+ const char* aModule, int aMajor, int aMinor);
+ void reRegisterType(const char* aQmlName,
+ const char* aModule, int aMajor, int aMinor);
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_PLUGIN_LOADER_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourSystemState.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2017 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -43,6 +43,8 @@
Q_OBJECT
Q_PROPERTY(QString displayStatus READ displayStatus NOTIFY displayStatusChanged)
Q_PROPERTY(QString lockMode READ lockMode NOTIFY lockModeChanged)
+ Q_PROPERTY(bool displayOff READ displayOff NOTIFY displayOffChanged)
+ Q_PROPERTY(bool locked READ locked NOTIFY lockedChanged)
Q_PROPERTY(QString MCE_DISPLAY_ON READ _MCE_DISPLAY_ON CONSTANT)
Q_PROPERTY(QString MCE_DISPLAY_DIM READ _MCE_DISPLAY_DIM CONSTANT)
@@ -71,7 +73,9 @@
Q_SIGNALS:
void displayStatusChanged();
+ void displayOffChanged();
void lockModeChanged();
+ void lockedChanged();
private:
// Getters for QML constants
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourTask.h
^
|
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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 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
+ * 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_TASK_H
+#define HARBOUR_TASK_H
+
+#include <QObject>
+#include <QRunnable>
+
+class QThread;
+class QThreadPool;
+
+/**
+ * A Runnable that queues done() signal to the target thread when it's done.
+ */
+class HarbourTask : public QObject, public QRunnable {
+ Q_OBJECT
+
+protected:
+ HarbourTask(QThreadPool* aPool, QThread* aTargetThread = NULL);
+
+public:
+ virtual ~HarbourTask();
+
+ bool isStarted() const;
+ bool isCanceled() const;
+
+ void submit();
+ void submit(QObject* aTarget, const char* aSlot);
+ void release(QObject* aHandler);
+ void release();
+
+private:
+ void released();
+
+protected:
+ virtual void run();
+ virtual void performTask() = 0;
+
+Q_SIGNALS:
+ void runFinished();
+ void done();
+
+private Q_SLOTS:
+ void onAboutToQuit();
+ void onRunFinished();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_TASK_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourTemporaryFile.h
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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:
+ *
+ * - 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.
+ *
+ * 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_TEMPORARY_FILE_H
+#define HARBOUR_TEMPORARY_FILE_H
+
+#include <QObject>
+#include <QString>
+#include <QUrl>
+
+class HarbourTemporaryFile: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString fileTemplate READ fileTemplate WRITE setFileTemplate NOTIFY fileTemplateChanged)
+ Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged)
+ Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged)
+ Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
+
+public:
+ explicit HarbourTemporaryFile(QObject* aParent = NULL);
+ ~HarbourTemporaryFile();
+
+ QString content() const;
+ void setContent(QString value);
+
+ QString fileTemplate() const;
+ void setFileTemplate(QString value);
+
+ QString fileName() const;
+ QUrl url() const;
+
+Q_SIGNALS:
+ void fileTemplateChanged();
+ void contentChanged();
+ void fileNameChanged();
+ void urlChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_TEMPORARY_FILE_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourTransferMethodInfo.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:
*
@@ -35,6 +35,7 @@
#include <QStringList>
#include <QtDBus/QtDBus>
+#include <QVariantHash>
class HarbourTransferMethodInfo
{
@@ -68,4 +69,40 @@
Q_DECLARE_METATYPE(HarbourTransferMethodInfo)
Q_DECLARE_METATYPE(QList<HarbourTransferMethodInfo>)
+// Extended transfer method info (available since Sailfish OS 2.2.0)
+class HarbourTransferMethodInfo2
+{
+public:
+ HarbourTransferMethodInfo2();
+ HarbourTransferMethodInfo2(const HarbourTransferMethodInfo& aInfo);
+ HarbourTransferMethodInfo2(const HarbourTransferMethodInfo2& aInfo);
+ HarbourTransferMethodInfo2& operator=(const HarbourTransferMethodInfo2& aInfo);
+ bool operator==(const HarbourTransferMethodInfo2& Info) const;
+ bool operator!=(const HarbourTransferMethodInfo2& Info) const;
+ bool equals(const HarbourTransferMethodInfo2& Info) const;
+
+ static void registerTypes();
+
+ QString displayName;
+ QString userName;
+ QString methodId;
+ QString shareUIPath;
+ QStringList capabilitities;
+ quint32 accountId;
+ QString accountIcon;
+ QVariantHash hints;
+};
+
+inline bool HarbourTransferMethodInfo2::operator==(const HarbourTransferMethodInfo2& aInfo) const
+ { return equals(aInfo); }
+inline bool HarbourTransferMethodInfo2::operator!=(const HarbourTransferMethodInfo2& aInfo) const
+ { return !equals(aInfo); }
+
+typedef QList<HarbourTransferMethodInfo2> HarbourTransferMethodInfo2List;
+QDBusArgument& operator<<(QDBusArgument& aArg, const HarbourTransferMethodInfo2& aInfo);
+const QDBusArgument& operator>>(const QDBusArgument& aArg, HarbourTransferMethodInfo2& aInfo);
+
+Q_DECLARE_METATYPE(HarbourTransferMethodInfo2)
+Q_DECLARE_METATYPE(QList<HarbourTransferMethodInfo2>)
+
#endif // HARBOUR_TRANSFER_METHOD_INFO_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/include/HarbourTransferMethodsModel.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:
*
@@ -44,6 +44,8 @@
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
+ Q_PROPERTY(bool accountIconSupported READ accountIconSupported NOTIFY accountIconSupportedChanged)
+ typedef QDBusPendingCallWatcher* (HarbourTransferMethodsModel::*RequestUpdate)();
public:
enum TransferMethodsRole {
@@ -51,7 +53,8 @@
UserNameRole,
MethodIdRole,
ShareUIPathRole,
- AccountIdRole
+ AccountIdRole,
+ AccountIconRole
};
public:
@@ -63,6 +66,7 @@
int count() const;
QString filter() const;
void setFilter(QString filter);
+ bool accountIconSupported() const;
int rowCount(const QModelIndex& aParent) const;
QVariant data(const QModelIndex& aIndex, int aRole) const;
@@ -73,21 +77,31 @@
private:
void filterModel();
static QRegExp regExp(QString aRegExp);
+ QDBusPendingCallWatcher* checkTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods2();
+ void setTransferMethods2(HarbourTransferMethodInfo2List aList);
private Q_SLOTS:
- void requestUpdate();
+ void onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch);
void onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch);
+ void onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch);
+ void requestUpdate();
Q_SIGNALS:
void countChanged();
void filterChanged();
+ void accountIconSupportedChanged();
private:
class TransferEngine;
TransferEngine* iTransferEngine;
QString iFilter;
- QList<HarbourTransferMethodInfo> iMethodList;
+ QList<HarbourTransferMethodInfo2> iMethodList;
QList<int> iFilteredList;
+ bool iAccountIconSupported;
+ RequestUpdate iRequestUpdate;
+ QDBusPendingCallWatcher* iUpdateWatcher;
};
#endif // HARBOUR_TRANSFER_METHODS_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourDisplayBlanking.cpp
^
|
@@ -0,0 +1,288 @@
+/*
+ * 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:
+ *
+ * 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 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
+ * 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 "HarbourDisplayBlanking.h"
+#include "HarbourDebug.h"
+#include "HarbourMce.h"
+
+#include <QDBusMessage>
+#include <QDBusConnection>
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
+#include <QTimer>
+
+// ==========================================================================
+// HarbourDisplayBlanking::Private
+// ==========================================================================
+class HarbourDisplayBlanking::Private : public HarbourMce {
+ Q_OBJECT
+
+public:
+ static const int REPEAT_INERVAL_SEC = 50;
+ static const QString BLANK_ACTIVE;
+ static const QString BLANK_INACTIVE;
+ static QWeakPointer<HarbourDisplayBlanking> sSharedInstance;
+
+ bool iPaused;
+ bool iPauseAllowed;
+ bool iPauseRequested;
+ bool iPauseActive;
+ QTimer* iRepeatTimer;
+
+ Private(HarbourDisplayBlanking* aParent);
+
+ void setPauseRequested(bool aValue);
+
+private:
+ HarbourDisplayBlanking* parentObject() const;
+ void updateDisplayBlankingPause(QString aState);
+ void updateDisplayBlankingAllowed(bool aAllowed);
+ void checkPause();
+ void requestPause();
+ void cancelPause();
+
+public Q_SLOTS:
+ void onDisplayBlankingPauseChanged(QString);
+ void onDisplayBlankingPauseAllowedChanged(bool);
+ void onDisplayBlankingPauseQueryDone(QDBusPendingCallWatcher*);
+ void onDisplayBlankingPauseAllowedQueryDone(QDBusPendingCallWatcher*);
+ void onRepeatBlankingRequest();
+};
+
+const QString HarbourDisplayBlanking::Private::BLANK_ACTIVE("active");
+const QString HarbourDisplayBlanking::Private::BLANK_INACTIVE("inactive");
+QWeakPointer<HarbourDisplayBlanking> HarbourDisplayBlanking::Private::sSharedInstance;
+
+HarbourDisplayBlanking::Private::Private(
+ HarbourDisplayBlanking* aParent) :
+ HarbourMce(aParent),
+ iPaused(false),
+ iPauseAllowed(false),
+ iPauseRequested(false),
+ iPauseActive(false),
+ iRepeatTimer(NULL)
+{
+ HDEBUG("created");
+ setupProperty("get_display_blanking_pause", "display_blanking_pause_ind",
+ SLOT(onDisplayBlankingPauseQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(onDisplayBlankingPauseChanged(QString)));
+ setupProperty("get_display_blanking_pause_allowed", "display_blanking_pause_allowed_ind",
+ SLOT(onDisplayBlankingPauseAllowedQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(onDisplayBlankingPauseAllowedChanged(bool)));
+}
+
+HarbourDisplayBlanking*
+HarbourDisplayBlanking::Private::parentObject() const
+{
+ return qobject_cast<HarbourDisplayBlanking*>(parent());
+}
+
+void
+HarbourDisplayBlanking::Private::updateDisplayBlankingPause(
+ QString aState)
+{
+ const bool paused = (aState == BLANK_ACTIVE);
+ if (iPaused != paused) {
+ iPaused = paused;
+ Q_EMIT parentObject()->pausedChanged();
+ }
+}
+
+void
+HarbourDisplayBlanking::Private::updateDisplayBlankingAllowed(
+ bool aAllowed)
+{
+ if (iPauseAllowed != aAllowed) {
+ iPauseAllowed = aAllowed;
+ Q_EMIT parentObject()->pauseAllowedChanged();
+ checkPause();
+ }
+}
+
+void
+HarbourDisplayBlanking::Private::onDisplayBlankingPauseChanged(
+ QString aState)
+{
+ HDEBUG(aState);
+ updateDisplayBlankingPause(aState);
+}
+
+void
+HarbourDisplayBlanking::Private::onDisplayBlankingPauseAllowedChanged(
+ bool aAllowed)
+{
+ HDEBUG(aAllowed);
+ updateDisplayBlankingAllowed(aAllowed);
+}
+
+void
+HarbourDisplayBlanking::Private::onDisplayBlankingPauseQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+ if (reply.isValid() && !reply.isError()) {
+ HDEBUG(reply);
+ updateDisplayBlankingPause(reply.value());
+ } else {
+ HWARN(reply.error());
+ }
+ aWatcher->deleteLater();
+}
+
+void
+HarbourDisplayBlanking::Private::onDisplayBlankingPauseAllowedQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<bool> reply(*aWatcher);
+ if (reply.isValid() && !reply.isError()) {
+ HDEBUG(reply);
+ updateDisplayBlankingAllowed(reply.value());
+ } else {
+ HWARN(reply.error());
+ updateDisplayBlankingAllowed(true);
+ }
+ aWatcher->deleteLater();
+}
+
+void
+HarbourDisplayBlanking::Private::setPauseRequested(
+ bool aValue)
+{
+ if (iPauseRequested != aValue) {
+ iPauseRequested = aValue;
+ HDEBUG(aValue);
+ Q_EMIT parentObject()->pauseRequestedChanged();
+ checkPause();
+ }
+}
+
+void
+HarbourDisplayBlanking::Private::checkPause()
+{
+ const bool active = iPauseRequested && iPauseAllowed;
+ if (iPauseActive != active) {
+ iPauseActive = active;
+ HDEBUG(active);
+ if (iPauseActive) {
+ if (!iRepeatTimer) {
+ iRepeatTimer = new QTimer(this);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourImageProvider.cpp
^
|
@@ -0,0 +1,286 @@
+/*
+ * 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 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
+ * 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 "HarbourImageProvider.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
+// ==========================================================================
+
+class HarbourImageProvider::TextureFactory : public QQuickTextureFactory
+{
+public:
+ TextureFactory(QString aPath, QSize requestedSize);
+
+ QSGTexture *createTexture(QQuickWindow *window) const Q_DECL_OVERRIDE;
+ QSize textureSize() const Q_DECL_OVERRIDE;
+ int textureByteCount() const Q_DECL_OVERRIDE;
+ QImage image() const Q_DECL_OVERRIDE;
+
+ QImage load() const;
+ static QImage colorize(QImage aImage, QColor aColor);
+
+private:
+ QString iPath;
+ QString iHighlight;
+ QSize iRequestedSize;
+ mutable QImage iImage;
+};
+
+HarbourImageProvider::TextureFactory::TextureFactory(
+ QString aPath,
+ QSize aRequestedSize) :
+ iRequestedSize(aRequestedSize)
+{
+ const int sep1 = aPath.lastIndexOf('?');
+ const int sep2 = aPath.lastIndexOf('/');
+ if (sep1 >= 0 && sep1 > sep2) {
+ iPath = aPath.left(sep1);
+ iHighlight = aPath.mid(sep1 + 1);
+ HDEBUG(iPath << iHighlight);
+ } else {
+ iPath = aPath;
+ }
+}
+
+QImage
+HarbourImageProvider::TextureFactory::load() const
+{
+ if (iImage.isNull() && !iPath.isEmpty()) {
+ QImageReader imageReader(iPath);
+ if (iRequestedSize.width() > 0 && iRequestedSize.height() > 0) {
+ 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));
+ }
+ } else {
+ // Colorization required
+ QColor highlightColor(iHighlight);
+ if (highlightColor.isValid()) {
+ HDEBUG(highlightColor);
+ iImage = colorize(iImage, highlightColor);
+ }
+ }
+ } else {
+ HWARN("can't load" << qPrintable(iPath));
+ }
+ }
+ return iImage;
+}
+
+QSize
+HarbourImageProvider::TextureFactory::textureSize() const
+{
+ return image().size();
+}
+
+int
+HarbourImageProvider::TextureFactory::textureByteCount() const
+{
+ QSize size(image().size());
+ return size.width() * size.height() * 4;
+}
+
+QImage
+HarbourImageProvider::TextureFactory::image() const
+{
+ return load();
+}
+
+QSGTexture*
+HarbourImageProvider::TextureFactory::createTexture(
+ QQuickWindow* aWindow) const
+{
+ if (!load().isNull()) {
+ QSGTexture* texture = aWindow->createTextureFromImage(iImage);
+ if (qEnvironmentVariableIsSet("QSG_TRANSIENT_IMAGES")) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourLib.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2017 Jolla Ltd.
- * Contact: 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:
*
@@ -33,7 +33,9 @@
#include "HarbourLib.h"
#include "HarbourDebug.h"
+#include "HarbourDisplayBlanking.h"
#include "HarbourSystemState.h"
+#include "HarbourTemporaryFile.h"
#include "HarbourTransferMethodsModel.h"
#if QT_VERSION >= 0x050000
@@ -42,8 +44,10 @@
# include <QtDeclarative/qdeclarative.h>
#endif
+QML_DECLARE_TYPE(HarbourDisplayBlanking)
QML_DECLARE_TYPE(HarbourSystemState)
QML_DECLARE_TYPE(HarbourTransferMethodsModel)
+QML_DECLARE_TYPE(HarbourTemporaryFile)
void
HarbourLib::registerTypes(
@@ -52,6 +56,8 @@
int aMinor)
{
HDEBUG(aUri << aMinor << aMajor);
+ qmlRegisterType<HarbourDisplayBlanking>(aUri, aMajor, aMinor, "DisplayBlanking");
qmlRegisterType<HarbourSystemState>(aUri, aMajor, aMinor, "SystemState");
+ qmlRegisterType<HarbourTemporaryFile>(aUri, aMajor, aMinor, "TemporaryFile");
qmlRegisterType<HarbourTransferMethodsModel>(aUri, aMajor, aMinor, "TransferMethodsModel");
}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourMce.cpp
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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:
+ *
+ * - 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.
+ *
+ * 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 "HarbourMce.h"
+
+#include <QDBusMessage>
+#include <QDBusConnection>
+#include <QDBusPendingCall>
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
+const QString HarbourMce::MCE_SERVICE("com.nokia.mce");
+const QString HarbourMce::MCE_REQUEST_PATH("/com/nokia/mce/request");
+const QString HarbourMce::MCE_REQUEST_INTERFACE("com.nokia.mce.request");
+const QString HarbourMce::MCE_SIGNAL_PATH("/com/nokia/mce/signal");
+const QString HarbourMce::MCE_SIGNAL_INTERFACE("com.nokia.mce.signal");
+
+HarbourMce::HarbourMce(QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+QDBusConnection
+HarbourMce::bus()
+{
+ return QDBusConnection::systemBus();
+}
+
+QDBusPendingCall
+HarbourMce::request(
+ QString aMethod)
+{
+ return bus().asyncCall(QDBusMessage::createMethodCall(MCE_SERVICE,
+ MCE_REQUEST_PATH, MCE_REQUEST_INTERFACE, aMethod));
+}
+
+void
+HarbourMce::setupProperty(
+ QString aQueryMethod,
+ QString aSignal,
+ const char* aQuerySlot,
+ const char* aSignalSlot)
+{
+ bus().connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_INTERFACE,
+ aSignal, this, aSignalSlot);
+ connect(new QDBusPendingCallWatcher(request(aQueryMethod), this),
+ SIGNAL(finished(QDBusPendingCallWatcher*)), this, aQuerySlot);
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourMce.h
^
|
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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:
+ *
+ * - 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.
+ *
+ * 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_MCE_H
+#define HARBOUR_MCE_H
+
+#include <QDBusConnection>
+#include <QDBusPendingCall>
+
+class HarbourMce : public QObject {
+ Q_OBJECT
+
+public:
+ static const QString MCE_SERVICE;
+ static const QString MCE_REQUEST_PATH;
+ static const QString MCE_REQUEST_INTERFACE;
+ static const QString MCE_SIGNAL_PATH;
+ static const QString MCE_SIGNAL_INTERFACE;
+
+ HarbourMce(QObject* aParent);
+ static QDBusConnection bus();
+ static QDBusPendingCall request(QString aMethod);
+ void setupProperty(QString aQueryMethod, QString aSignal,
+ const char* aQuerySlot, const char* aSignalSlot);
+};
+
+#endif // HARBOUR_MCE_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2017 Jolla Ltd.
+ * Copyright (C) 2017 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 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 "HarbourPluginLoader.h"
+#include "HarbourDebug.h"
+
+// These are included from qqmlengine.h
+#include <QUrl>
+#include <QObject>
+#include <QMap>
+#include <QJSEngine>
+#include <QQmlError>
+
+#if QT_VERSION >= 0x050000
+
+// Unprotect QQmlEngine::d_func
+#define private public
+#include <QQmlEngine>
+#undef private
+
+#include <qqml.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+
+#include <dlfcn.h>
+
+// This hack allows (in most cases) to use prohibited QML imports by
+// re-registering them under a different name
+
+// These:
+// QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction() const
+// _ZNK8QQmlType26attachedPropertiesFunctionEv
+//
+// const QMetaObject* QQmlType::attachedPropertiesType() const
+// _ZNK8QQmlType22attachedPropertiesTypeEv
+//
+// have been replaced with these in Qt 5.6:
+//
+// QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate*) const
+// _ZNK8QQmlType26attachedPropertiesFunctionEP17QQmlEnginePrivate
+//
+// const QMetaObject* QQmlType::attachedPropertiesType(QQmlEnginePrivate*) const
+// _ZNK8QQmlType22attachedPropertiesTypeEP17QQmlEnginePrivate
+//
+
+#define LIBQT5QML_SO "/usr/lib/libQt5Qml.so.5"
+
+// sym,ret,name,args
+#define QMLTYPE_FUNCTIONS(f) \
+ f("_ZNK8QQmlType26attachedPropertiesFunctionEv", \
+ QQmlAttachedPropertiesFunc, AttachedPropertiesFunctionProc,(QQmlType*)) \
+ f("_ZNK8QQmlType22attachedPropertiesTypeEv", \
+ const QMetaObject*, AttachedPropertiesTypeProc,(QQmlType*)) \
+ f("_ZNK8QQmlType26attachedPropertiesFunctionEP17QQmlEnginePrivate", \
+ QQmlAttachedPropertiesFunc, AttachedPropertiesFunctionProc6, (QQmlType*,QQmlEnginePrivate*)) \
+ f("_ZNK8QQmlType22attachedPropertiesTypeEP17QQmlEnginePrivate", \
+ const QMetaObject*, AttachedPropertiesTypeProc6, (QQmlType*,QQmlEnginePrivate*))
+
+// PRIVATE QT API!
+class Q_QML_EXPORT QQmlType
+{
+public:
+ int typeId() const;
+ int qListTypeId() const;
+ typedef void (*CreateFunc)(void *);
+ CreateFunc createFunction() const;
+ int createSize() const;
+ const QMetaObject *metaObject() const;
+ int parserStatusCast() const;
+ int propertyValueSourceCast() const;
+ int propertyValueInterceptorCast() const;
+ QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
+ const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const;
+};
+
+// PRIVATE QT API!
+class Q_QML_EXPORT QQmlMetaType
+{
+public:
+ static QQmlType* qmlType(const QString &qualifiedName, int, int);
+};
+
+static const char* QmlTypeSymbols[] = {
+#define QMLTYPE_SYMBOL(sym,ret,name,args) sym,
+ QMLTYPE_FUNCTIONS(QMLTYPE_SYMBOL)
+};
+
+typedef struct _QmlTypeFunctions {
+#define QMLTYPE_TYPEDEF(sym,ret,name,args) ret (*name) args;
+QMLTYPE_FUNCTIONS(QMLTYPE_TYPEDEF)
+} QmlTypeFunctions;
+
+#define _N(a) (sizeof(a)/sizeof((a)[0]))
+#define NUM_FUNCTIONS _N(QmlTypeSymbols)
+Q_STATIC_ASSERT(sizeof(QmlTypeFunctions) == NUM_FUNCTIONS*sizeof(void*));
+
+// ==========================================================================
+// HarbourPluginLoader::Private
+// ==========================================================================
+
+class HarbourPluginLoader::Private {
+public:
+ Private(QQmlEngine* aEngine, QString aModule, int aMajor, int aMinor);
+ ~Private();
+
+ QQmlType* qmlType(QString aName);
+
+ void reRegisterType(QQmlType* aType, const char* aQmlName,
+ const char* aModule, int aMajor, int aMinor);
+ void reRegisterType(const char* aOriginalQmlName, const char* aNewQmlName,
+ const char* aModule, int aMajor, int aMinor);
+ void reRegisterType(const char* aQmlName,
+ const char* aModule, int aMajor, int aMinor);
+
+public:
+ QQmlEngine* iEngine;
+ QString iModule;
+ int iMajor;
+ int iMinor;
+ bool iLoaded;
+ void* iHandle;
+ union {
+ QmlTypeFunctions fn;
+ void* ptr[NUM_FUNCTIONS];
+ } iLibQt5Qml;
+};
+
+HarbourPluginLoader::Private::Private(
+ QQmlEngine* aEngine,
+ QString aModule,
+ int aMajor,
+ int aMinor) :
+ iEngine(aEngine),
+ iModule(aModule),
+ iMajor(aMajor),
+ iMinor(aMinor),
+ iLoaded(false),
+ iHandle(NULL)
+{
+ memset(&iLibQt5Qml, 0, sizeof(iLibQt5Qml));
+ // Load the actual import library
+ QQmlComponent* component = new QQmlComponent(iEngine);
+ component->setData(QString("import QtQuick 2.0\nimport %1 %2.%3\nQtObject {}").
+ arg(iModule).arg(iMajor).arg(iMinor).toUtf8(), QUrl());
+ if (component->status() == QQmlComponent::Ready) {
+ delete component->create();
+ // Resolve unstable symbols
+ iHandle = dlopen(LIBQT5QML_SO, RTLD_LAZY);
+ if (iHandle) {
+ for (uint i = 0; i < NUM_FUNCTIONS; i++) {
+ iLibQt5Qml.ptr[i] = dlsym(iHandle, QmlTypeSymbols[i]);
+ HDEBUG(QmlTypeSymbols[i] << (iLibQt5Qml.ptr[i] ? "OK" : "missing"));
+ }
+ } else {
+ HWARN("Failed to load" << LIBQT5QML_SO);
+ }
+ iLoaded = true;
+ } else {
+ HWARN(component->errors());
+ }
+ delete component;
+}
+
+HarbourPluginLoader::Private::~Private()
+{
+ if (iHandle) {
+ dlclose(iHandle);
+ }
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourSystemState.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2016 Jolla Ltd.
- * Contact: 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:
*
@@ -33,6 +33,7 @@
#include "HarbourSystemState.h"
#include "HarbourDebug.h"
+#include "HarbourMce.h"
#include <QDBusMessage>
#include <QDBusConnection>
@@ -40,8 +41,6 @@
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
-#define MCE_SERVICE "com.nokia.mce"
-
const QString HarbourSystemState::MCE_DISPLAY_ON("on");
const QString HarbourSystemState::MCE_DISPLAY_DIM("dimmed");
const QString HarbourSystemState::MCE_DISPLAY_OFF("off");
@@ -51,8 +50,7 @@
// ==========================================================================
// HarbourSystemState::Private
// ==========================================================================
-class HarbourSystemState::Private : public QObject
-{
+class HarbourSystemState::Private : public HarbourMce {
Q_OBJECT
public:
@@ -63,9 +61,10 @@
Private(HarbourSystemState* aParent);
+ bool displayOff() const;
+ bool locked() const;
+
private:
- void setupProperty(QString aQueryMethod, QString aSignal,
- const char* aQuerySlot, const char* aSignalSlot);
void setDisplayStatus(QString aStatus);
void setLockMode(QString aStatus);
@@ -80,7 +79,7 @@
HarbourSystemState::Private::Private(
HarbourSystemState* aParent) :
- QObject(aParent),
+ HarbourMce(aParent),
iParent(aParent)
{
HDEBUG("created");
@@ -92,20 +91,10 @@
SLOT(onLockModeChanged(QString)));
}
-void
-HarbourSystemState::Private::setupProperty(
- QString aQueryMethod,
- QString aSignal,
- const char* aQuerySlot,
- const char* aSignalSlot)
-{
- QDBusConnection systemBus(QDBusConnection::systemBus());
- connect(new QDBusPendingCallWatcher(systemBus.asyncCall(
- QDBusMessage::createMethodCall(MCE_SERVICE, "/com/nokia/mce/request",
- "com.nokia.mce.request", aQueryMethod)), this),
- SIGNAL(finished(QDBusPendingCallWatcher*)), this, aQuerySlot);
- systemBus.connect(MCE_SERVICE, "/com/nokia/mce/signal",
- "com.nokia.mce.signal", aSignal, this, aSignalSlot);
+bool
+HarbourSystemState::Private::displayOff() const
+{
+ return iDisplayStatus == MCE_DISPLAY_OFF;
}
void
@@ -113,8 +102,13 @@
QString aStatus)
{
if (iDisplayStatus != aStatus) {
+ const bool displayWasOff = displayOff();
iDisplayStatus = aStatus;
+ const bool displayIsOff = displayOff();
Q_EMIT iParent->displayStatusChanged();
+ if (displayWasOff != displayIsOff) {
+ Q_EMIT iParent->displayOffChanged();
+ }
}
}
@@ -138,13 +132,24 @@
aWatcher->deleteLater();
}
+bool
+HarbourSystemState::Private::locked() const
+{
+ return iLockMode == MCE_TK_LOCKED;
+}
+
void
HarbourSystemState::Private::setLockMode(
QString aMode)
{
if (iLockMode != aMode) {
+ const bool wasLocked = locked();
iLockMode = aMode;
+ const bool isLocked = locked();
Q_EMIT iParent->lockModeChanged();
+ if (wasLocked != isLocked) {
+ Q_EMIT iParent->lockedChanged();
+ }
}
}
@@ -214,13 +219,13 @@
bool
HarbourSystemState::displayOff() const
{
- return iPrivate->iDisplayStatus == MCE_DISPLAY_OFF;
+ return iPrivate->displayOff();
}
bool
HarbourSystemState::locked() const
{
- return iPrivate->iLockMode == MCE_TK_LOCKED;
+ return iPrivate->locked();
}
#include "HarbourSystemState.moc"
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourTask.cpp
^
|
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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 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
+ * 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 "HarbourTask.h"
+#include "HarbourDebug.h"
+
+#include <QCoreApplication>
+#include <QThreadPool>
+
+// ==========================================================================
+// HarbourTask::Private
+// ==========================================================================
+
+class HarbourTask::Private {
+public:
+ Private(QThreadPool* aPool);
+
+public:
+ QThreadPool* iPool;
+ bool iAboutToQuit;
+ bool iSubmitted;
+ bool iStarted;
+ bool iReleased;
+ bool iDone;
+};
+
+HarbourTask::Private::Private(QThreadPool* aPool) :
+ iPool(aPool),
+ iAboutToQuit(false),
+ iSubmitted(false),
+ iStarted(false),
+ iReleased(false),
+ iDone(false)
+{
+}
+
+// ==========================================================================
+// HarbourTask
+// ==========================================================================
+
+HarbourTask::HarbourTask(QThreadPool* aPool, QThread* aTargetThread) :
+ QObject(aTargetThread ? NULL : aPool), // Cannot move objects with a parent
+ iPrivate(new Private(aPool))
+{
+ if (aTargetThread) moveToThread(aTargetThread);
+ setAutoDelete(false);
+ connect(qApp, SIGNAL(aboutToQuit()), SLOT(onAboutToQuit()));
+ connect(this, SIGNAL(runFinished()), SLOT(onRunFinished()),
+ Qt::QueuedConnection);
+}
+
+HarbourTask::~HarbourTask()
+{
+ HASSERT(iPrivate->iReleased);
+ if (iPrivate->iSubmitted) wait();
+ delete iPrivate;
+}
+
+bool HarbourTask::isStarted() const
+{
+ return iPrivate->iStarted;
+}
+
+bool HarbourTask::isCanceled() const
+{
+ return iPrivate->iReleased || iPrivate->iAboutToQuit;
+}
+
+void HarbourTask::submit()
+{
+ HASSERT(!iPrivate->iSubmitted);
+ HASSERT(iPrivate->iPool);
+ if (iPrivate->iPool && !iPrivate->iSubmitted) {
+ iPrivate->iSubmitted = true;
+ iPrivate->iPool->start(this);
+ }
+}
+
+void HarbourTask::submit(QObject* aTarget, const char* aSlot)
+{
+ aTarget->connect(this, SIGNAL(done()), aSlot);
+ submit();
+}
+
+void HarbourTask::release(QObject* aHandler)
+{
+ disconnect(aHandler);
+ released();
+}
+
+void HarbourTask::release()
+{
+ disconnect();
+ released();
+}
+
+void HarbourTask::released()
+{
+ iPrivate->iReleased = true;
+ if (!iPrivate->iSubmitted || iPrivate->iDone) {
+ delete this;
+ }
+}
+
+void HarbourTask::run()
+{
+ HASSERT(!iPrivate->iStarted);
+ iPrivate->iStarted = true;
+ performTask();
+ Q_EMIT runFinished();
+}
+
+void HarbourTask::onRunFinished()
+{
+ HASSERT(!iPrivate->iDone);
+ if (!iPrivate->iReleased) {
+ Q_EMIT done();
+ }
+ iPrivate->iDone = true;
+ if (iPrivate->iReleased) {
+ delete this;
+ }
+}
+
+void HarbourTask::onAboutToQuit()
+{
+ HDEBUG("OK");
+ iPrivate->iAboutToQuit = true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourTemporaryFile.cpp
^
|
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 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:
+ *
+ * - 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.
+ *
+ * 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 "HarbourTemporaryFile.h"
+#include "HarbourDebug.h"
+
+#include <QDir>
+#include <QTemporaryFile>
+#include <QTextStream>
+
+// ==========================================================================
+// HarbourTemporaryFile::Private
+// ==========================================================================
+
+class HarbourTemporaryFile::Private {
+public:
+ Private();
+ ~Private();
+
+ void reopen(HarbourTemporaryFile* aObject);
+ QString fileName() const;
+
+public:
+ QTemporaryFile* iFile;
+ QString iFileTemplate;
+ QString iContent;
+ QUrl iUrl;
+};
+
+HarbourTemporaryFile::Private::Private() :
+ iFile(NULL)
+{
+}
+
+HarbourTemporaryFile::Private::~Private()
+{
+ if (iFile) {
+ iFile->close();
+ delete iFile;
+ }
+}
+
+inline QString
+HarbourTemporaryFile::Private::fileName() const
+{
+ return iFile ? iFile->fileName() : QString();
+}
+
+void
+HarbourTemporaryFile::Private::reopen(
+ HarbourTemporaryFile* aObject)
+{
+ const QString oldFileName = fileName();
+ QString newFileName;
+ if (iFile && iFile->isOpen()) {
+ iFile->close();
+ delete iFile;
+ iFile = NULL;
+ iUrl = QUrl();
+ }
+ if (!iContent.isEmpty() && !iFileTemplate.isEmpty()) {
+ iFile = new QTemporaryFile(QDir::tempPath() +
+ QDir::separator() + iFileTemplate);
+ iFile->setAutoRemove(true);
+ if (iFile->open()) {
+ newFileName = iFile->fileName();
+ iUrl = QUrl::fromLocalFile(newFileName);
+ HDEBUG("writing" << qPrintable(newFileName));
+ QTextStream stream(iFile);
+ stream << iContent;
+ stream.flush();
+ } else {
+ HWARN("Failed to open temporary file");
+ delete iFile;
+ iFile = NULL;
+ }
+ }
+ if (fileName() != oldFileName) {
+ Q_EMIT aObject->fileNameChanged();
+ Q_EMIT aObject->urlChanged();
+ }
+}
+
+// ==========================================================================
+// HarbourTemporaryFile
+// ==========================================================================
+
+HarbourTemporaryFile::HarbourTemporaryFile(
+ QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private)
+{
+}
+
+HarbourTemporaryFile::~HarbourTemporaryFile()
+{
+ delete iPrivate;
+}
+
+QString
+HarbourTemporaryFile::content() const
+{
+ return iPrivate->iContent;
+}
+
+void
+HarbourTemporaryFile::setContent(QString aValue)
+{
+ if (iPrivate->iContent != aValue) {
+ iPrivate->iContent = aValue;
+ iPrivate->reopen(this);
+ Q_EMIT contentChanged();
+ }
+}
+
+QString
+HarbourTemporaryFile::fileTemplate() const
+{
+ return iPrivate->iFileTemplate;
+}
+
+void
+HarbourTemporaryFile::setFileTemplate(QString aValue)
+{
+ if (iPrivate->iFileTemplate != aValue) {
+ iPrivate->iFileTemplate = aValue;
+ iPrivate->reopen(this);
+ Q_EMIT fileTemplateChanged();
+ }
+}
+
+QString
+HarbourTemporaryFile::fileName() const
+{
+ return iPrivate->fileName();
+}
+
+QUrl
+HarbourTemporaryFile::url() const
+{
+ return iPrivate->iUrl;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourTransferMethodInfo.cpp
^
|
@@ -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:
*
@@ -32,6 +32,10 @@
#include "HarbourTransferMethodInfo.h"
+// ==========================================================================
+// HarbourTransferMethodInfo
+// ==========================================================================
+
QDBusArgument &operator<<(QDBusArgument& aArg, const HarbourTransferMethodInfo& aInfo)
{
aArg.beginStructure();
@@ -91,3 +95,86 @@
qDBusRegisterMetaType<HarbourTransferMethodInfo>();
qDBusRegisterMetaType<HarbourTransferMethodInfoList>();
}
+
+// ==========================================================================
+// HarbourTransferMethodInfo2
+// ==========================================================================
+
+QDBusArgument &operator<<(QDBusArgument& aArg, const HarbourTransferMethodInfo2& aInfo)
+{
+ aArg.beginStructure();
+ aArg << aInfo.displayName << aInfo.userName << aInfo.methodId
+ << aInfo.shareUIPath << aInfo.capabilitities << aInfo.accountId
+ << aInfo.accountIcon << aInfo.hints;
+ aArg.endStructure();
+ return aArg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument& aArg, HarbourTransferMethodInfo2& aInfo)
+{
+ aArg.beginStructure();
+ aArg >> aInfo.displayName >> aInfo.userName >> aInfo.methodId
+ >> aInfo.shareUIPath >> aInfo.capabilitities >> aInfo.accountId
+ >> aInfo.accountIcon >> aInfo.hints;
+ aArg.endStructure();
+ return aArg;
+}
+
+HarbourTransferMethodInfo2::HarbourTransferMethodInfo2():
+ accountId(0)
+{
+}
+
+HarbourTransferMethodInfo2::HarbourTransferMethodInfo2(const HarbourTransferMethodInfo2& aInfo):
+ displayName(aInfo.displayName),
+ userName(aInfo.userName),
+ methodId(aInfo.methodId),
+ shareUIPath(aInfo.shareUIPath),
+ capabilitities(aInfo.capabilitities),
+ accountId(aInfo.accountId),
+ accountIcon(aInfo.accountIcon),
+ hints(aInfo.hints)
+{
+}
+
+HarbourTransferMethodInfo2::HarbourTransferMethodInfo2(const HarbourTransferMethodInfo& aInfo):
+ displayName(aInfo.displayName),
+ userName(aInfo.userName),
+ methodId(aInfo.methodId),
+ shareUIPath(aInfo.shareUIPath),
+ capabilitities(aInfo.capabilitities),
+ accountId(aInfo.accountId)
+{
+}
+
+HarbourTransferMethodInfo2& HarbourTransferMethodInfo2::operator=(const HarbourTransferMethodInfo2& aInfo)
+{
+ displayName = aInfo.displayName;
+ userName = aInfo.userName;
+ methodId = aInfo.methodId;
+ shareUIPath = aInfo.shareUIPath;
+ capabilitities = aInfo.capabilitities;
+ accountId = aInfo.accountId;
+ accountIcon = aInfo.accountIcon;
+ hints = aInfo.hints;
+ return *this;
+}
+
+bool HarbourTransferMethodInfo2::equals(const HarbourTransferMethodInfo2& aInfo) const
+{
+ return displayName == aInfo.displayName &&
+ userName == aInfo.userName &&
+ methodId == aInfo.methodId &&
+ shareUIPath == aInfo.shareUIPath &&
+ capabilitities == aInfo.capabilitities &&
+ accountId == aInfo.accountId &&
+ accountIcon == aInfo.accountIcon &&
+ hints == aInfo.hints;
+}
+
+void HarbourTransferMethodInfo2::registerTypes()
+{
+ HarbourTransferMethodInfo::registerTypes();
+ qDBusRegisterMetaType<HarbourTransferMethodInfo2>();
+ qDBusRegisterMetaType<HarbourTransferMethodInfo2List>();
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/harbour-lib/src/HarbourTransferMethodsModel.cpp
^
|
@@ -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:
*
@@ -54,6 +54,8 @@
public: // METHODS
inline QDBusPendingCall transferMethods()
{ return asyncCall("transferMethods"); }
+ inline QDBusPendingCall transferMethods2()
+ { return asyncCall("transferMethods2"); }
Q_SIGNALS: // SIGNALS
void transferMethodListChanged();
@@ -68,7 +70,10 @@
// ==========================================================================
HarbourTransferMethodsModel::HarbourTransferMethodsModel(QObject* aParent):
- QAbstractListModel(aParent)
+ QAbstractListModel(aParent),
+ iAccountIconSupported(false),
+ iRequestUpdate(&HarbourTransferMethodsModel::checkTransferMethods),
+ iUpdateWatcher(NULL)
{
iTransferEngine = new TransferEngine(this);
connect(iTransferEngine,
@@ -95,23 +100,107 @@
void HarbourTransferMethodsModel::requestUpdate()
{
- connect(new QDBusPendingCallWatcher(
- iTransferEngine->transferMethods(), this),
- SIGNAL(finished(QDBusPendingCallWatcher*)),
+ if (iUpdateWatcher) {
+ HDEBUG("dropping pending call");
+ iUpdateWatcher->disconnect(this);
+ delete iUpdateWatcher;
+ iUpdateWatcher = NULL;
+ }
+ iUpdateWatcher = (this->*iRequestUpdate)();
+}
+
+void HarbourTransferMethodsModel::setTransferMethods2(HarbourTransferMethodInfo2List aList)
+{
+ iRequestUpdate = &HarbourTransferMethodsModel::requestTransferMethods2;
+ HDEBUG(aList.count() << "methods");
+ if (iMethodList != aList) {
+ iMethodList = aList;
+ filterModel();
+ }
+ if (!iAccountIconSupported) {
+ iAccountIconSupported = true;
+ Q_EMIT accountIconSupportedChanged();
+ }
+}
+
+QDBusPendingCallWatcher* HarbourTransferMethodsModel::checkTransferMethods()
+{
+ // First try transferMethods2() and see if it works
+ QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher
+ (iTransferEngine->transferMethods2(), this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(onTransferMethodsCheckFinished(QDBusPendingCallWatcher*)));
+ return watcher;
+}
+
+QDBusPendingCallWatcher* HarbourTransferMethodsModel::requestTransferMethods()
+{
+ QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher
+ (iTransferEngine->transferMethods(), this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
SLOT(onTransferMethodsFinished(QDBusPendingCallWatcher*)));
+ return watcher;
+}
+
+QDBusPendingCallWatcher* HarbourTransferMethodsModel::requestTransferMethods2()
+{
+ QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher
+ (iTransferEngine->transferMethods2(), this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ SLOT(onTransferMethods2Finished(QDBusPendingCallWatcher*)));
+ return watcher;
+}
+
+void HarbourTransferMethodsModel::onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch)
+{
+ QDBusPendingReply<HarbourTransferMethodInfo2List> reply(*aWatch);
+ aWatch->deleteLater();
+ HASSERT(aWatch == iUpdateWatcher);
+ iUpdateWatcher = NULL;
+ if (reply.isError()) {
+ QDBusError error(reply.error());
+ qWarning() << error;
+ if (error.type() == QDBusError::UnknownMethod) {
+ // Switch to the legacy interface
+ iRequestUpdate = &HarbourTransferMethodsModel::requestTransferMethods;
+ requestUpdate();
+ }
+ } else {
+ setTransferMethods2(reply.value());
+ }
+}
+
+void HarbourTransferMethodsModel::onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch)
+{
+ QDBusPendingReply<HarbourTransferMethodInfo2List> reply(*aWatch);
+ aWatch->deleteLater();
+ HASSERT(aWatch == iUpdateWatcher);
+ iUpdateWatcher = NULL;
+ if (reply.isError()) {
+ qWarning() << reply.error();
+ } else {
+ setTransferMethods2(reply.value());
+ }
}
void HarbourTransferMethodsModel::onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch)
{
QDBusPendingReply<HarbourTransferMethodInfoList> reply(*aWatch);
aWatch->deleteLater();
+ HASSERT(aWatch == iUpdateWatcher);
+ iUpdateWatcher = NULL;
if (reply.isError()) {
- qWarning() << reply.error().message();
+ qWarning() << reply.error();
} else {
- HarbourTransferMethodInfoList list = reply.value();
- HDEBUG(list.count() << "methods");
- if (iMethodList != list) {
- iMethodList = list;
+ const HarbourTransferMethodInfoList list = reply.value();
+ HarbourTransferMethodInfo2List list2;
+ const int n = list.count();
+ for (int i = 0; i < n; i++) {
+ list2.append(HarbourTransferMethodInfo2(list.at(i)));
+ }
+ HDEBUG(n << "methods");
+ if (iMethodList != list2) {
+ iMethodList = list2;
filterModel();
}
}
@@ -125,6 +214,7 @@
roles[MethodIdRole] = "methodId";
roles[ShareUIPathRole] = "shareUIPath";
roles[AccountIdRole] = "accountId";
+ roles[AccountIconRole] = "accountIcon";
return roles;
}
@@ -137,7 +227,7 @@
{
int row = index.row();
if (row >= 0 && row < iFilteredList.count()) {
- const HarbourTransferMethodInfo& info = iMethodList.at(iFilteredList.at(row));
+ const HarbourTransferMethodInfo2& info = iMethodList.at(iFilteredList.at(row));
switch (role) {
case DisplayNameRole: {
QString s(qApp->translate(NULL, qPrintable(info.displayName)));
@@ -150,6 +240,7 @@
case UserNameRole: return info.userName;
case ShareUIPathRole: return info.shareUIPath;
case AccountIdRole: return info.accountId;
+ case AccountIconRole: return info.accountIcon;
}
}
qWarning() << index << role;
@@ -161,6 +252,11 @@
return iFilteredList.count();
}
+bool HarbourTransferMethodsModel::accountIconSupported() const
+{
+ return iAccountIconSupported;
+}
+
QString HarbourTransferMethodsModel::filter() const
{
return iFilter;
@@ -193,7 +289,7 @@
} else {
QRegExp re(regExp(iFilter));
for (int i=0; i<iMethodList.count(); i++) {
- const HarbourTransferMethodInfo& info = iMethodList.at(i);
+ const HarbourTransferMethodInfo2& info = iMethodList.at(i);
for (int j=0; j<info.capabilitities.count(); j++) {
const QString& cap = info.capabilitities.at(j);
if (iFilter == cap ||
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/qml/pages/CategoryPage.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2017 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -40,31 +40,31 @@
property string searchString
onSearchStringChanged: {
- console.log(searchString)
filterModel.setFilterFixedString(searchString)
}
PullDownMenu {
+ id: menu
visible: canEnableDisable || canReset
- readonly property bool canEnableDisable: filterModel.count > 0
+ readonly property bool canEnableDisable: filterModel && filterModel.count > 0
readonly property bool canReset: filterModel.haveDefaults
MenuItem {
//% "Enable all"
text: qsTrId("logger-categories-pm-enable-all")
onClicked: filterModel.enableAll()
- visible: canEnableDisable
+ visible: menu.canEnableDisable
}
MenuItem {
//% "Disable all"
text: qsTrId("logger-categories-pm-disable-all")
onClicked: filterModel.disableAll()
- visible: canEnableDisable
+ visible: menu.canEnableDisable
}
MenuItem {
//% "Reset to default"
text: qsTrId("logger-categories-pm-default")
onClicked: filterModel.reset()
- visible: canReset
+ visible: menu.canReset
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/qml/pages/MainPage.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2017 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -66,15 +66,11 @@
sourceComponent: modelData
}
}
- onWidthChanged: updateCurrentIndex()
- onContentXChanged: updateCurrentIndex()
- function updateCurrentIndex() {
- currentIndex = indexAt(contentX + width/2, contentY + height/2)
- }
+ highlightRangeMode: ListView.StrictlyEnforceRange
onCurrentIndexChanged: {
if (currentIndex && swipeHintEnabled) {
- // Use has seen the second page
- loggerHints.categoryLeftSwipe++
+ // User has seen the second page
+ loggerHints.categoryLeftSwipe = loggerHints.categoryLeftSwipeMax
if (swipeHint.item) {
swipeHint.item.stop()
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/qml/pages/ShareMethodList.qml
^
|
@@ -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:
*
@@ -63,13 +63,26 @@
id: backgroundItem
width: root.width
+ Image {
+ id: icon
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: accountIcon ? accountIcon :
+ transferMethodsModel.accountIconSupported ? "image://theme/icon-m-share" : ""
+ visible: transferMethodsModel.accountIconSupported
+ }
+
Label {
id: displayNameLabel
text: displayName
color: backgroundItem.highlighted ? Theme.highlightColor : Theme.primaryColor
truncationMode: TruncationMode.Fade
x: Theme.horizontalPageMargin
- anchors.verticalCenter: parent.verticalCenter
+ anchors {
+ left: icon.visible ? icon.right : parent.left
+ leftMargin: icon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
width: Math.min(implicitWidth, parent.width - 2*Theme.horizontalPageMargin)
}
@@ -80,7 +93,7 @@
truncationMode: TruncationMode.Fade
anchors {
left: displayNameLabel.right
- leftMargin: Theme.horizontalPageMargin
+ leftMargin: Theme.paddingSmall
right: parent.right
rightMargin: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
@@ -103,11 +116,26 @@
}
footer: BackgroundItem {
+ id: addItem
+
+ Image {
+ id: addAccountIcon
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: transferMethodsModel.accountIconSupported ?
+ ("image://theme/icon-m-add" + (addItem.highlighted ? "?" + Theme.highlightColor : "")) : ""
+ visible: transferMethodsModel.accountIconSupported
+ }
+
Label {
//% "Add account"
text: qsTrId("logger-sharemethodlist-add-account")
x: Theme.horizontalPageMargin
- anchors.verticalCenter: parent.verticalCenter
+ anchors {
+ left: addAccountIcon.visible ? addAccountIcon.right : parent.left
+ leftMargin: addAccountIcon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
color: highlighted ? Theme.highlightColor : Theme.primaryColor
}
onClicked: settings.call("showAccounts", undefined)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/qml/pages/SharePage.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2017 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -38,9 +38,14 @@
id: page
property var logSaver: LogSaver
allowedOrientations: window.allowedOrientations
- backNavigation: _canShare
property bool _canShare: !logSaver.packing && !logSaver.saving && !minWaitTimer.running
+ // For the page slide animation to kick in, the initial value of
+ // backNavigation has to be true. Once the transition has started,
+ // backNavigation is turned off until the log has been saved.
+ showNavigationIndicator: status !== PageStatus.Inactive
+ backNavigation: status === PageStatus.Inactive || _canShare
+
// The timer makes sure that animation is displayed for at least 1 second
Timer {
id: minWaitTimer
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/LoggerMain.cpp
^
|
@@ -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:
*
@@ -80,7 +80,7 @@
{
QString pluginPrefix(QString("harbour.logger.") + aPackage);
register_types(qPrintable(pluginPrefix));
- HarbourTransferMethodInfo::registerTypes();
+ HarbourTransferMethodInfo2::registerTypes();
}
LoggerMain::~LoggerMain()
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/VERSION
^
|
@@ -1 +1 @@
-1.0.6
+1.0.11
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/client/include/dbuslog_client_types.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -34,7 +34,6 @@
#define DBUSLOG_CLIENT_TYPES_H
#include <glib.h>
-#include <glib-object.h>
G_BEGIN_DECLS
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/client/src/dbuslog_receiver.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -36,6 +36,8 @@
#include <gutil_misc.h>
+#include <glib-object.h>
+
/* Log module */
GLOG_MODULE_DEFINE("dbuslog");
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/rpm/libdbuslog.spec
^
|
@@ -1,5 +1,5 @@
Name: dbuslog-tools
-Version: 1.0.6
+Version: 1.0.11
Release: 0
Summary: Command line client for libdbuslogserver
Group: Development/Tools
@@ -7,6 +7,7 @@
URL: https://git.merproject.org/mer-core/libdbuslog
Source: %{name}-%{version}.tar.bz2
Requires: libglibutil >= 1.0.9
+BuildRequires: pkgconfig(libdbusaccess)
BuildRequires: pkgconfig(libglibutil)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/Makefile
^
|
@@ -7,7 +7,7 @@
# Required packages
#
-PKGS = libglibutil glib-2.0
+PKGS = libdbusaccess libglibutil glib-2.0
GIO_PKGS = gio-2.0 gio-unix-2.0
DBUS_PKGS = dbus-1
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/include/dbus/dbuslog_server_dbus.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -41,6 +41,11 @@
DBusConnection* conn,
const char* path);
+DBusLogServer*
+dbus_log_server_new_type(
+ DBusBusType type,
+ const char* path);
+
#endif /* DBUSLOG_SERVER_LIBDBUS_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/include/dbuslog_server.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -71,6 +71,11 @@
dbus_log_server_stop(
DBusLogServer* server);
+gboolean
+dbus_log_server_set_access_policy(
+ DBusLogServer* server,
+ const char* spec);
+
DBUSLOG_LEVEL
dbus_log_server_default_level(
DBusLogServer* server);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/include/dbuslog_server_types.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -34,7 +34,6 @@
#define DBUSLOG_SERVER_TYPES_H
#include <glib.h>
-#include <glib-object.h>
#define DBUSLOG_SERVER_LOG_MODULE dbuslog_server_log
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/src/dbus/dbuslog_server_dbus.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -36,6 +36,7 @@
#include <gutil_strv.h>
#include <unistd.h>
+#include <errno.h>
typedef struct dbus_log_server_dbus DBusLogServerDbus;
typedef struct dbus_log_name_watch {
@@ -257,19 +258,54 @@
static
DBusMessage*
+dbus_log_server_error(
+ DBusMessage* msg,
+ int err)
+{
+ const char* type;
+ const char* message;
+ switch (err) {
+ case -EACCES:
+ type = DBUS_ERROR_ACCESS_DENIED;
+ message = "Access denied";
+ break;
+ case -EINVAL:
+ type = DBUS_ERROR_INVALID_ARGS;
+ message = "Invalid argument(s)";
+ break;
+ default:
+ type = DBUS_ERROR_FAILED;
+ message = "Internal error";
+ break;
+ }
+ return dbus_message_new_error(msg, type, message);
+}
+
+static
+DBusMessage*
+dbus_log_server_return(
+ DBusMessage* msg,
+ int err)
+{
+ return (err < 0) ? dbus_log_server_error(msg, err) :
+ dbus_message_new_method_return(msg);
+}
+
+static
+DBusMessage*
dbus_log_server_dbus_handle_set_default_level(
DBusLogServerDbus* self,
DBusMessage* msg)
{
+ int err = -EINVAL;
dbus_int32_t level = DBUSLOG_LEVEL_UNDEFINED;
if (dbus_message_get_args(msg, NULL,
DBUS_TYPE_INT32, &level,
- DBUS_TYPE_INVALID) &&
- dbus_log_server_set_default_level(&self->server, level)) {
- return dbus_message_new_method_return(msg);
- } else {
- return dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, "");
+ DBUS_TYPE_INVALID)) {
+ err = dbus_log_server_call_set_default_level(&self->server,
+ dbus_message_get_sender(msg), level);
}
+ return dbus_log_server_return(msg, err);
}
static
@@ -278,17 +314,17 @@
DBusLogServerDbus* self,
DBusMessage* msg)
{
+ int err = -EINVAL;
const char* name = NULL;
dbus_int32_t level = DBUSLOG_LEVEL_UNDEFINED;
if (dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INT32, &level,
DBUS_TYPE_INVALID)) {
- dbus_log_core_set_category_level(self->server.core, name, level);
- return dbus_message_new_method_return(msg);
- } else {
- return dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, "");
+ err = dbus_log_server_call_set_category_level(&self->server, name,
+ dbus_message_get_sender(msg), level);
}
+ return dbus_log_server_return(msg, err);
}
static
@@ -297,20 +333,20 @@
DBusLogServerDbus* self,
DBusMessage* msg)
{
- DBusMessage* reply;
- int fd = dbus_log_server_open(&self->server, dbus_message_get_sender(msg));
+ int fd = dbus_log_server_call_log_open(&self->server,
+ dbus_message_get_sender(msg));
if (fd >= 0) {
DBusMessageIter it;
const dbus_uint32_t cookie = DBUSLOG_LOG_COOKIE;
- reply = dbus_message_new_method_return(msg);
+ DBusMessage* reply = dbus_message_new_method_return(msg);
dbus_message_iter_init_append(reply, &it);
dbus_message_iter_append_basic(&it, DBUS_TYPE_UNIX_FD, &fd);
dbus_message_iter_append_basic(&it, DBUS_TYPE_UINT32, &cookie);
close(fd);
+ return reply;
} else {
- reply = dbus_message_new_error(msg, DBUS_ERROR_FAILED, "");
+ return dbus_log_server_error(msg, fd);
}
- return reply;
}
static
@@ -323,7 +359,8 @@
dbus_uint32_t cookie;
dbus_message_iter_init(msg, &it);
dbus_message_iter_get_basic(&it, &cookie);
- dbus_log_server_close(&self->server, dbus_message_get_sender(msg), cookie);
+ dbus_log_server_call_log_close(&self->server,
+ dbus_message_get_sender(msg), cookie);
return dbus_message_new_method_return(msg);
}
@@ -334,6 +371,7 @@
DBusMessage* msg,
gboolean enable)
{
+ int err;
GStrV* names = NULL;
DBusMessageIter it, array;
dbus_message_iter_init(msg, &it);
@@ -344,9 +382,10 @@
names = gutil_strv_add(names, name);
dbus_message_iter_next(&array);
}
- dbus_log_server_set_names_enabled(&self->server, names, enable);
+ err = dbus_log_server_call_set_names_enabled(&self->server,
+ dbus_message_get_sender(msg), names, enable);
g_strfreev(names);
- return dbus_message_new_method_return(msg);
+ return dbus_log_server_return(msg, err);
}
static
@@ -356,12 +395,15 @@
DBusMessage* msg,
gboolean enable)
{
+ int err = -EINVAL;
const char* pattern = NULL;
- DBusMessageIter it;
- dbus_message_iter_init(msg, &it);
- dbus_message_iter_get_basic(&it, &pattern);
- dbus_log_server_set_pattern_enabled(&self->server, pattern, enable);
- return dbus_message_new_method_return(msg);
+ if (dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID)) {
+ err = dbus_log_server_call_set_pattern_enabled(&self->server,
+ dbus_message_get_sender(msg), pattern, enable);
+ }
+ return dbus_log_server_return(msg, err);
}
static
@@ -603,6 +645,21 @@
dbus_log_server_dbus_filter,self);
}
+static
+DBusLogServer*
+dbus_log_server_new_full(
+ DBusConnection* conn,
+ DBusBusType type,
+ const char* path)
+{
+ DBusLogServerDbus* self = g_object_new(DBUSLOG_SERVER_DBUS_TYPE, NULL);
+ DBusLogServer* server = &self->server;
+ dbus_log_server_initialize(server, (type == DBUS_BUS_SYSTEM) ?
+ DBUSLOG_BUS_SYSTEM : DBUSLOG_BUS_SESSION, path);
+ self->conn = dbus_connection_ref(conn);
+ return server;
+}
+
/*==========================================================================*
* API
*==========================================================================*/
@@ -612,10 +669,21 @@
DBusConnection* conn,
const char* path)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/src/dbuslog_sender.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -36,6 +36,8 @@
#include "dbuslog_server_types.h"
#include "dbuslog_message.h"
+#include <glib-object.h>
+
typedef struct dbus_log_sender_priv DBusLogSenderPriv;
typedef struct dbus_log_sender {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/src/dbuslog_server.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -33,7 +33,10 @@
#include "dbuslog_server_p.h"
#include "dbuslog_server_log.h"
+#include <dbusaccess_policy.h>
+#include <dbusaccess_peer.h>
#include <gutil_misc.h>
+#include <errno.h>
enum dbus_log_server_core_signal {
DBUSLOG_CORE_SIGNAL_DEFAULT_LEVEL,
@@ -52,6 +55,8 @@
struct dbus_log_server_priv {
char* path;
+ DA_BUS bus;
+ DAPolicy* policy;
GHashTable* peers;
gulong core_signal_id[DBUSLOG_CORE_SIGNAL_COUNT];
};
@@ -74,6 +79,27 @@
static guint dbus_log_server_signals[SIGNAL_COUNT] = { 0 };
+/* Queries are always allowed */
+typedef enum dbuslog_action {
+ DBUSLOG_ACTION_SET_DEFAULT_LEVEL = 1,
+ DBUSLOG_ACTION_SET_CATEGORY_LEVEL,
+ DBUSLOG_ACTION_LOG_OPEN,
+ DBUSLOG_ACTION_CATEGORY_ENABLE,
+ DBUSLOG_ACTION_CATEGORY_DISABLE
+} DBUSLOG_ACTION;
+
+static const DA_ACTION dbus_log_server_policy_actions[] = {
+ { "SetDefaultLevel", DBUSLOG_ACTION_SET_DEFAULT_LEVEL, 0 },
+ { "SetCategoryLevel", DBUSLOG_ACTION_SET_CATEGORY_LEVEL, 0 },
+ { "LogOpen", DBUSLOG_ACTION_LOG_OPEN, 0 },
+ { "CategoryEnable", DBUSLOG_ACTION_CATEGORY_ENABLE, 0 },
+ { "CategoryDisable", DBUSLOG_ACTION_CATEGORY_DISABLE, 0 },
+ { NULL }
+};
+
+static const char dbus_log_server_default_policy[] =
+ DA_POLICY_VERSION ";group(privileged)=allow";
+
/*==========================================================================*
* Implementation
*==========================================================================*/
@@ -176,33 +202,85 @@
}
}
+static
+gboolean
+dbus_log_server_access_allowed(
+ DBusLogServer* self,
+ const char* sender,
+ DBUSLOG_ACTION action)
+{
+ /* If we get no peer information from dbus-daemon, it means that
+ * the peer is gone so it doesn't really matter what we do in this
+ * case - the reply will be dropped anyway. */
+ DBusLogServerPriv* priv = self->priv;
+ DAPeer* peer = da_peer_get(priv->bus, sender);
+ return peer && da_policy_check(priv->policy, &peer->cred, action, 0,
+ DA_ACCESS_DENY) == DA_ACCESS_ALLOW;
+}
+
/*==========================================================================*
* D-Bus method helpers
*==========================================================================*/
int
-dbus_log_server_open(
+dbus_log_server_call_set_default_level(
+ DBusLogServer* self,
+ const char* sender,
+ DBUSLOG_LEVEL level)
+{
+ if (!dbus_log_server_access_allowed(self, sender,
+ DBUSLOG_ACTION_SET_DEFAULT_LEVEL)) {
+ return -EACCES;
+ } else if (!dbus_log_core_set_default_level(self->core, level)) {
+ return -EINVAL;
+ } else {
+ return 0;
+ }
+}
+
+int
+dbus_log_server_call_set_category_level(
+ DBusLogServer* self,
+ const char* sender,
+ const char* name,
+ DBUSLOG_LEVEL level)
+{
+ if (!dbus_log_server_access_allowed(self, sender,
+ DBUSLOG_ACTION_SET_CATEGORY_LEVEL)) {
+ return -EACCES;
+ } else {
+ dbus_log_core_set_category_level(self->core, name, level);
+ return 0;
+ }
+}
+
+int
+dbus_log_server_call_log_open(
DBusLogServer* self,
const char* name)
{
- DBusLogSender* sender = dbus_log_core_new_sender(self->core, name);
- if (sender) {
- DBusLogServerPriv* priv = self->priv;
- DBusLogServerPeer* peer = g_slice_new0(DBusLogServerPeer);
- DBusLogServerClass* klass = DBUSLOG_SERVER_GET_CLASS(self);
- peer->sender = sender;
- peer->server = self;
- if (klass->watch_name) {
- peer->watch_id = klass->watch_name(self, name);
+ if (!dbus_log_server_access_allowed(self, name, DBUSLOG_ACTION_LOG_OPEN)) {
+ return -EACCES;
+ } else {
+ DBusLogSender* sender = dbus_log_core_new_sender(self->core, name);
+ if (sender) {
+ DBusLogServerPriv* priv = self->priv;
+ DBusLogServerPeer* peer = g_slice_new0(DBusLogServerPeer);
+ DBusLogServerClass* klass = DBUSLOG_SERVER_GET_CLASS(self);
+ peer->sender = sender;
+ peer->server = self;
+ if (klass->watch_name) {
+ peer->watch_id = klass->watch_name(self, name);
+ }
+ g_hash_table_replace(priv->peers, (gpointer)sender->name, peer);
+ return sender->readfd;
}
- g_hash_table_replace(priv->peers, (gpointer)sender->name, peer);
- return sender->readfd;
+ return -EIO;
}
- return -1;
}
void
-dbus_log_server_close(
+dbus_log_server_call_log_close(
DBusLogServer* self,
const char* name,
guint cookie)
@@ -212,31 +290,49 @@
g_hash_table_remove(priv->peers, name);
}
-void
-dbus_log_server_set_names_enabled(
+int
+dbus_log_server_call_set_names_enabled(
DBusLogServer* self,
+ const char* sender,
const GStrV* names,
gboolean enable)
{
- if (G_LIKELY(self) && names) {
- const GStrV* ptr;
- for (ptr = names; *ptr; ptr++) {
- dbus_log_core_set_category_enabled(self->core, *ptr, enable);
+ const DBUSLOG_ACTION action = enable ?
+ DBUSLOG_ACTION_CATEGORY_ENABLE :
+ DBUSLOG_ACTION_CATEGORY_DISABLE;
+ if (!dbus_log_server_access_allowed(self, sender, action)) {
+ return -EACCES;
+ } else {
+ if (names) {
+ const GStrV* ptr;
+ for (ptr = names; *ptr; ptr++) {
+ dbus_log_core_set_category_enabled(self->core, *ptr, enable);
+ }
}
+ return 0;
}
}
-void
-dbus_log_server_set_pattern_enabled(
+int
+dbus_log_server_call_set_pattern_enabled(
DBusLogServer* self,
+ const char* sender,
const char* pattern,
gboolean enable)
{
- guint i;
- GPtrArray* cats = dbus_log_core_find_categories(self->core, pattern);
- for (i=0; i<cats->len; i++) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/src/dbuslog_server_p.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -43,6 +43,11 @@
typedef struct dbus_log_server_priv DBusLogServerPriv;
+typedef enum dbus_log_server_bus {
+ DBUSLOG_BUS_SYSTEM,
+ DBUSLOG_BUS_SESSION
+} DBUSLOG_BUS;
+
struct dbus_log_server {
GObject object;
DBusLogServerPriv* priv;
@@ -104,6 +109,7 @@
void
dbus_log_server_initialize(
DBusLogServer* self,
+ DBUSLOG_BUS bus,
const char* path);
void
@@ -112,25 +118,40 @@
const char* name);
int
-dbus_log_server_open(
+dbus_log_server_call_set_default_level(
+ DBusLogServer* server,
+ const char* peer,
+ DBUSLOG_LEVEL level);
+
+int
+dbus_log_server_call_set_category_level(
+ DBusLogServer* server,
+ const char* peer,
+ const char* name,
+ DBUSLOG_LEVEL level);
+
+int
+dbus_log_server_call_log_open(
DBusLogServer* server,
const char* peer);
void
-dbus_log_server_close(
+dbus_log_server_call_log_close(
DBusLogServer* server,
const char* peer,
guint cookie);
-void
-dbus_log_server_set_names_enabled(
+int
+dbus_log_server_call_set_names_enabled(
DBusLogServer* server,
+ const char* peer,
const GStrV* names,
gboolean enable);
-void
-dbus_log_server_set_pattern_enabled(
+int
+dbus_log_server_call_set_pattern_enabled(
DBusLogServer* self,
+ const char* peer,
const char* pattern,
gboolean enable);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/server/src/gio/dbuslog_server_gio.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -37,6 +37,7 @@
#include <gutil_misc.h>
#include <gio/gunixfdlist.h>
+#include <errno.h>
/* Generated headers */
#include "org.nemomobile.Logger.h"
@@ -249,6 +250,32 @@
}
}
+static
+void
+dbus_log_server_return_error(
+ GDBusMethodInvocation* call,
+ int err)
+{
+ guint code;
+ const char* message;
+ switch (err) {
+ case -EACCES:
+ code = G_DBUS_ERROR_ACCESS_DENIED;
+ message = "Access denied";
+ break;
+ case -EINVAL:
+ code = G_DBUS_ERROR_INVALID_ARGS;
+ message = "Invalid argument(s)";
+ break;
+ default:
+ code = G_DBUS_ERROR_FAILED;
+ message = "Internal error";
+ break;
+ }
+ g_dbus_method_invocation_return_error_literal(call, G_DBUS_ERROR,
+ code, message);
+}
+
/*==========================================================================*
* D-Bus methods
*==========================================================================*/
@@ -296,8 +323,13 @@
gint level,
DBusLogServerGio* self)
{
- dbus_log_core_set_default_level(self->server.core, level);
- org_nemomobile_logger_complete_set_default_level(proxy, call);
+ int err = dbus_log_server_call_set_default_level(&self->server,
+ g_dbus_method_invocation_get_sender(call), level);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_set_default_level(proxy, call);
+ }
return TRUE;
}
@@ -310,8 +342,13 @@
gint level,
DBusLogServerGio* self)
{
- dbus_log_core_set_category_level(self->server.core, name, level);
- org_nemomobile_logger_complete_set_category_level(proxy, call);
+ int err = dbus_log_server_call_set_category_level(&self->server,
+ g_dbus_method_invocation_get_sender(call), name, level);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_set_category_level(proxy, call);
+ }
return TRUE;
}
@@ -323,10 +360,11 @@
GUnixFDList* fdlist,
DBusLogServerGio* self)
{
+ int err = -EFAULT;
GASSERT(self->bus);
if (self->bus) {
- const char* name = g_dbus_method_invocation_get_sender(call);
- const gint fd = dbus_log_server_open(&self->server, name);
+ const gint fd = dbus_log_server_call_log_open(&self->server,
+ g_dbus_method_invocation_get_sender(call));
if (fd >= 0) {
GUnixFDList* fdl = g_unix_fd_list_new_from_array(&fd, 1);
org_nemomobile_logger_complete_log_open(proxy, call, fdl,
@@ -334,9 +372,9 @@
g_object_unref(fdl);
return TRUE;
}
+ err = fd;
}
- g_dbus_method_invocation_return_error(call, G_DBUS_ERROR,
- G_DBUS_ERROR_FAILED, "Failed to create DBusLogSender");
+ dbus_log_server_return_error(call, err);
return TRUE;
}
@@ -348,8 +386,8 @@
guint cookie,
DBusLogServerGio* self)
{
- const char* name = g_dbus_method_invocation_get_sender(call);
- dbus_log_server_close(&self->server, name, cookie);
+ dbus_log_server_call_log_close(&self->server,
+ g_dbus_method_invocation_get_sender(call), cookie);
org_nemomobile_logger_complete_log_close(proxy, call);
return TRUE;
}
@@ -362,8 +400,13 @@
const GStrV* names,
DBusLogServerGio* self)
{
- dbus_log_server_set_names_enabled(&self->server, names, TRUE);
- org_nemomobile_logger_complete_category_enable(proxy, call);
+ const int err = dbus_log_server_call_set_names_enabled(&self->server,
+ g_dbus_method_invocation_get_sender(call), names, TRUE);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_category_enable(proxy, call);
+ }
return TRUE;
}
@@ -375,8 +418,13 @@
const char* pattern,
DBusLogServerGio* self)
{
- dbus_log_server_set_pattern_enabled(&self->server, pattern, TRUE);
- org_nemomobile_logger_complete_category_enable_pattern(proxy, call);
+ const int err = dbus_log_server_call_set_pattern_enabled(&self->server,
+ g_dbus_method_invocation_get_sender(call), pattern, TRUE);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_category_enable_pattern(proxy, call);
+ }
return TRUE;
}
@@ -388,8 +436,13 @@
const GStrV* names,
DBusLogServerGio* self)
{
- dbus_log_server_set_names_enabled(&self->server, names, FALSE);
- org_nemomobile_logger_complete_category_enable(proxy, call);
+ const int err = dbus_log_server_call_set_names_enabled(&self->server,
+ g_dbus_method_invocation_get_sender(call), names, FALSE);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_category_enable(proxy, call);
+ }
return TRUE;
}
@@ -401,8 +454,13 @@
const char* pattern,
DBusLogServerGio* self)
{
- dbus_log_server_set_pattern_enabled(&self->server, pattern, FALSE);
- org_nemomobile_logger_complete_category_enable_pattern(proxy, call);
+ const int err = dbus_log_server_call_set_pattern_enabled(&self->server,
+ g_dbus_method_invocation_get_sender(call), pattern, FALSE);
+ if (err) {
+ dbus_log_server_return_error(call, err);
+ } else {
+ org_nemomobile_logger_complete_category_enable_pattern(proxy, call);
+ }
return TRUE;
}
@@ -418,7 +476,8 @@
{
DBusLogServerGio* self = g_object_new(DBUSLOG_SERVER_GIO_TYPE, NULL);
DBusLogServer* server = &self->server;
- dbus_log_server_initialize(server, path);
+ dbus_log_server_initialize(server, (bus_type == G_BUS_TYPE_SYSTEM) ?
+ DBUSLOG_BUS_SYSTEM : DBUSLOG_BUS_SESSION, path);
/* Attach to the D-Bus signals */
self->iface = org_nemomobile_logger_skeleton_new();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libdbuslog/tools/dbuslog-client/main.c
^
|
@@ -59,7 +59,11 @@
DBusLogClientCall* call;
AppAction* actions;
gboolean follow;
+ gboolean datetime;
+ gboolean timestamp;
gboolean print_log_level;
+ char* out_filename;
+ FILE* out_file;
gulong event_id[APP_N_EVENTS];
gint timeout;
guint timeout_id;
@@ -210,7 +214,7 @@
printf("%s: %s%s\n", cat->name,
(cat->flags & DBUSLOG_CATEGORY_FLAG_ENABLED) ? "on" : "off",
(cat->flags & DBUSLOG_CATEGORY_FLAG_ENABLED_BY_DEFAULT) ?
- "|default" : "");
+ "|default" : "");
}
action->fn_free(action);
return NULL;
@@ -260,6 +264,16 @@
static
DBusLogClientCall*
+app_action_disable_all(
+ AppAction* action)
+{
+ GDEBUG("Disabling all categories");
+ return dbus_log_client_disable_pattern(action->app->client, "*",
+ app_action_call_done, action);
+}
+
+static
+DBusLogClientCall*
app_action_enable(
AppAction* action)
{
@@ -344,16 +358,56 @@
static
void
+app_print(
+ App* app,
+ const char* format,
+ ...)
+{
+ va_list va;
+ va_start(va, format);
+ vprintf(format, va);
+ va_end(va);
+ if (app->out_file) {
+ va_start(va, format);
+ if (vfprintf(app->out_file, format, va) < 0) {
+ GERR("Error writing %s: %s", app->out_filename, strerror(errno));
+ fclose(app->out_file);
+ app->out_file = NULL;
+ }
+ va_end(va);
+ }
+}
+
+static
+void
client_message(
DBusLogClient* client,
DBusLogCategory* category,
DBusLogMessage* message,
gpointer user_data)
{
+ App* app = user_data;
+ const char* prefix;
+ char buf[32];
+ if (app->timestamp || app->datetime) {
+ const char* format = app->datetime ? "%F %T" : "%T";
+ const time_t t = (time_t)(message->timestamp/1000000);
+ const int ms = (int)(message->timestamp%1000000)/1000;
+ struct tm tm;
+ gsize len;
+ localtime_r(&t, &tm);
+ buf[0] = buf[G_N_ELEMENTS(buf)-1] = 0;
+ strftime(buf, G_N_ELEMENTS(buf)-1, format, &tm);
+ len = strlen(buf);
+ snprintf(buf + len, G_N_ELEMENTS(buf) - len - 1, ".%03d ", ms);
+ prefix = buf;
+ } else{
+ prefix = "";
+ }
if (category && !(category->flags & DBUSLOG_CATEGORY_FLAG_HIDE_NAME)) {
- printf("%s: %s\n", category->name, message->string);
+ app_print(app, "%s%s: %s\n", prefix, category->name, message->string);
} else {
- printf("%s\n", message->string);
+ app_print(app, "%s%s\n", prefix, message->string);
}
}
@@ -370,6 +424,16 @@
if (!app->client->started) {
GDEBUG("Starting live capture...");
dbus_log_client_start(app->client, NULL, NULL);
+ if (app->out_filename && !app->out_file) {
+ app->out_file = fopen(app->out_filename, "w");
+ if (app->out_file) {
+ GDEBUG("Writing %s", app->out_filename);
+ } else {
+ GERR("Can't open %s: %s", app->out_filename, strerror(errno));
+ g_free(app->out_filename);
+ app->out_filename = NULL;
+ }
+ }
}
}
@@ -510,6 +574,19 @@
static
gboolean
+app_option_disable_all(
+ const gchar* name,
+ const gchar* value,
+ gpointer data,
+ GError** error)
+{
+ App* app = data;
+ app_add_action(app, app_action_new(app, app_action_disable_all));
+ return TRUE;
+}
+
+static
+gboolean
app_option_enable(
const gchar* name,
const gchar* value,
@@ -596,6 +673,12 @@
GOptionEntry action_entries[] = {
{ "follow", 'f', 0, G_OPTION_ARG_NONE, &app->follow,
"Print log messages to stdout (default action)", NULL },
+ { "write", 'w', 0, G_OPTION_ARG_FILENAME, &app->out_filename,
+ "Write message to file too (requires -f)", "FILE" },
+ { "timestamp", 'T', 0, G_OPTION_ARG_NONE, &app->timestamp,
+ "Print message time (use -D to print the date too)", NULL },
+ { "date", 'D', 0, G_OPTION_ARG_NONE, &app->datetime,
+ "Print message time and date", NULL },
{ "categories", 'c', 0, G_OPTION_ARG_NONE, &list,
"List log categories", NULL },
{ "print-log-level", 'L', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
@@ -604,6 +687,8 @@
"Set the log level (1..8)", "LEVEL" },
{ "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,
+ app_option_disable_all, "Disable all log categories", NULL },
{ "enable", 'e', 0, G_OPTION_ARG_CALLBACK, app_option_enable,
"Enable log categories (repeatable)", "PATTERN" },
{ "disable", 'd', 0, G_OPTION_ARG_CALLBACK, app_option_disable,
@@ -640,6 +725,11 @@
/* Default action */
app->follow = TRUE;
}
+ if (app->out_filename && !app->follow) {
+ GWARN("Ignoring -w option (it requires -f)");
+ g_free(app->out_filename);
+ app->out_filename = NULL;
+ }
ok = TRUE;
} else {
char* help = g_option_context_get_help(options, TRUE, NULL);
@@ -654,6 +744,26 @@
return ok;
}
+static
+void
+app_destroy(
+ App* app)
+{
+ if (app->out_file) {
+ fclose(app->out_file);
+ app->out_file = NULL;
+ }
+ if (app->out_filename) {
+ g_free(app->out_filename);
+ app->out_filename = NULL;
+ }
+ while (app->actions) {
+ AppAction* action = app->actions;
+ app->actions = action->next;
+ action->fn_free(action);
+ }
+}
+
int main(int argc, char* argv[])
{
int ret = RET_ERR;
@@ -664,12 +774,8 @@
gutil_log_default.level = GLOG_LEVEL_DEFAULT;
if (app_init(&app, argc, argv)) {
ret = app_run(&app);
- while (app.actions) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/Makefile
^
|
@@ -20,7 +20,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 17
+VERSION_RELEASE = 29
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
@@ -42,10 +42,14 @@
#
SRC = \
- gutil_log.c \
+ gutil_history.c \
+ gutil_idlepool.c \
+ gutil_idlequeue.c \
gutil_inotify.c \
+ gutil_intarray.c \
+ gutil_ints.c \
+ gutil_log.c \
gutil_misc.c \
- gutil_idlepool.c \
gutil_ring.c \
gutil_strv.c \
gutil_timenotify.c
@@ -121,6 +125,7 @@
endif
endif
+$(PKGCONFIG): | $(BUILD_DIR)
$(DEBUG_OBJS) $(DEBUG_LIB): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS) $(RELEASE_LIB): | $(RELEASE_BUILD_DIR)
@@ -133,9 +138,9 @@
DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
-debug: $(DEBUG_LIB) $(DEBUG_LINK)
+debug: $(DEBUG_LIB)
-release: $(RELEASE_LIB) $(RELEASE_LINK)
+release: $(RELEASE_LIB)
pkgconfig: $(PKGCONFIG)
@@ -169,7 +174,7 @@
test:
make -C test test
-$(GEN_DIR):
+$(BUILD_DIR):
mkdir -p $@
$(DEBUG_BUILD_DIR):
@@ -186,19 +191,15 @@
$(DEBUG_LIB): $(DEBUG_OBJS)
$(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) -o $@
+ ln -sf $(LIB) $(DEBUG_LINK)
$(RELEASE_LIB): $(RELEASE_OBJS)
$(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) -o $@
+ ln -sf $(LIB) $(RELEASE_LINK)
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif
-$(DEBUG_LINK):
- ln -sf $(LIB) $@
-
-$(RELEASE_LINK):
- ln -sf $(LIB) $@
-
$(PKGCONFIG): $(LIB_NAME).pc.in
sed -e 's/\[version\]/'$(PCVERSION)/g $< > $@
@@ -207,8 +208,6 @@
#
INSTALL_PERM = 644
-INSTALL_OWNER = $(shell id -u)
-INSTALL_GROUP = $(shell id -g)
INSTALL = install
INSTALL_DIRS = $(INSTALL) -d
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/debian/changelog
^
|
@@ -1,3 +1,87 @@
+libglibutil (1.0.29) unstable; urgency=low
+
+ * Added gutil_hexdump function
+ * Fixed dependencies for pkgconfig target
+
+ -- Slava Monich <slava.monich@jolla.com> Tue, 13 Mar 2018 19:28:46 +0300
+
+libglibutil (1.0.28) unstable; urgency=low
+
+ * Added gutil_idle_pool_get function
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 25 Feb 2018 19:58:21 +0200
+
+libglibutil (1.0.27) unstable; urgency=low
+
+ * GUtilIdlePool is not a GObject anymore
+ * Took out glib-object.h from public headers
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 25 Feb 2018 13:20:49 +0200
+
+libglibutil (1.0.26) unstable; urgency=low
+
+ * Optimized GUtilIdleQueue
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 25 Nov 2017 02:16:18 +0200
+
+libglibutil (1.0.25) unstable; urgency=low
+
+ * Allow NULL module in gutil_log_enabled
+ * Added test_log
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 19 Oct 2017 19:51:05 +0300
+
+libglibutil (1.0.24) unstable; urgency=low
+
+ * Added gutil_strv_strip function
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 18 Jun 2017 00:27:35 +0300
+
+libglibutil (1.0.23) unstable; urgency=low
+
+ * Added a few more GUtilIntArray functions
+
+ gutil_int_array_new_from_vals
+ gutil_int_array_new_from_value
+ gutil_int_array_find
+ gutil_int_array_contains
+ gutil_int_array_remove
+ gutil_int_array_remove_fast
+ gutil_int_array_remove_all
+ gutil_int_array_remove_all_fast
+
+ -- Slava Monich <slava.monich@jolla.com> Mon, 05 Jun 2017 19:01:12 +0300
+
+libglibutil (1.0.22) unstable; urgency=low
+
+ * Added GUtilIdleQueue
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 23 Apr 2017 18:07:46 +0300
+
+libglibutil (1.0.21) unstable; urgency=low
+
+ * Added gutil_hex2bin and gutil_hex2bytes functions
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 10 Mar 2017 23:36:04 +0200
+
+libglibutil (1.0.20) unstable; urgency=low
+
+ * Added GUtilIntHistory
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 02 Mar 2017 16:58:02 +0200
+
+libglibutil (1.0.19) unstable; urgency=low
+
+ * Added GUtilIntArray and GUtilInts
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 23 Feb 2017 18:37:01 +0200
+
+libglibutil (1.0.18) unstable; urgency=low
+
+ * Allow strings longer than 512 bytes in gutil_log_syslog
+
+ -- Slava Monich <slava.monich@jolla.com> Sat, 18 Feb 2017 20:30:23 +0200
+
libglibutil (1.0.17) unstable; urgency=low
* Made unit tests work with glib < 2.36
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_history.h
^
|
@@ -0,0 +1,114 @@
+/*
+ * 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 GUTIL_HISTORY_H
+#define GUTIL_HISTORY_H
+
+#include "gutil_types.h"
+
+G_BEGIN_DECLS
+
+/*
+ * A history of values. Keeps track of no more than last X values submitted
+ * within the last Y microseconds. Microsecond precision may sound like a bit
+ * of an overkill but that's what glib functions like g_get_monotonic_time
+ * return.
+ *
+ * Currently it's only useful for calculating the median but the API could
+ * be extended to provide access to the individual samples, if anyone ever
+ * needs that.
+ *
+ * Also, it's calculating median rather than the average taking into account
+ * that samples are not necessarily added to the history at uniform intervals.
+ * If someone needs the straight average, it's easy enough to add API for that
+ * too.
+ *
+ * When you call gutil_int_history_add but the time hasn't changed since the
+ * last gutil_int_history_add call, the last value is replaced (as opposed to
+ * adding a new entry).
+ */
+
+#define GUTIL_HISTORY_SEC ((gint64)(G_USEC_PER_SEC))
+typedef gint64 (*GUtilHistoryTimeFunc)(void);
+
+GUtilIntHistory*
+gutil_int_history_new(
+ int max_size,
+ gint64 max_interval);
+
+GUtilIntHistory*
+gutil_int_history_new_full(
+ int max_size,
+ gint64 max_interval,
+ GUtilHistoryTimeFunc time_fn);
+
+GUtilIntHistory*
+gutil_int_history_ref(
+ GUtilIntHistory* history);
+
+void
+gutil_int_history_unref(
+ GUtilIntHistory* history);
+
+guint
+gutil_int_history_size(
+ GUtilIntHistory* history);
+
+gint64
+gutil_int_history_interval(
+ GUtilIntHistory* history);
+
+void
+gutil_int_history_clear(
+ GUtilIntHistory* history);
+
+int
+gutil_int_history_add(
+ GUtilIntHistory* history,
+ int value);
+
+int
+gutil_int_history_median(
+ GUtilIntHistory* history,
+ int default_value);
+
+G_END_DECLS
+
+#endif /* GUTIL_HISTORY_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_idlepool.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -56,17 +56,15 @@
* gutil_idle_pool_add_variant_ref()
* gutil_idle_pool_add_ptr_array_ref()
*/
-typedef struct gutil_idle_pool GUtilIdlePool;
-
-GType gutil_idle_pool_get_type();
-#define GUTIL_IDLE_POOL_TYPE (gutil_idle_pool_get_type())
-#define GUTIL_IDLE_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- GUTIL_IDLE_POOL_TYPE, GUtilIdlePool))
GUtilIdlePool*
gutil_idle_pool_new(void);
GUtilIdlePool*
+gutil_idle_pool_get(
+ GUtilIdlePool** shared);
+
+GUtilIdlePool*
gutil_idle_pool_ref(
GUtilIdlePool* pool);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_idlequeue.h
^
|
@@ -0,0 +1,119 @@
+/*
+ * 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 GUTIL_IDLEQUEUE_H
+#define GUTIL_IDLEQUEUE_H
+
+#include "gutil_types.h"
+
+G_BEGIN_DECLS
+
+/*
+ * GUtilIdleQueue allows to queue idle callbacks, tag them, cancel
+ * individual callbacks or all of them.
+ */
+
+typedef gsize GUtilIdleQueueTag;
+
+typedef
+void
+(*GUtilIdleFunc)(
+ gpointer data);
+
+GUtilIdleQueue*
+gutil_idle_queue_new(void);
+
+void
+gutil_idle_queue_free(
+ GUtilIdleQueue* queue);
+
+GUtilIdleQueue*
+gutil_idle_queue_ref(
+ GUtilIdleQueue* queue);
+
+void
+gutil_idle_queue_unref(
+ GUtilIdleQueue* queue);
+
+void
+gutil_idle_queue_add(
+ GUtilIdleQueue* queue,
+ GUtilIdleFunc run,
+ gpointer data);
+
+void
+gutil_idle_queue_add_full(
+ GUtilIdleQueue* queue,
+ GUtilIdleFunc run,
+ gpointer data,
+ GFreeFunc free);
+
+void
+gutil_idle_queue_add_tag(
+ GUtilIdleQueue* queue,
+ GUtilIdleQueueTag tag,
+ GUtilIdleFunc run,
+ gpointer data);
+
+void
+gutil_idle_queue_add_tag_full(
+ GUtilIdleQueue* queue,
+ GUtilIdleQueueTag tag,
+ GUtilIdleFunc run,
+ gpointer data,
+ GFreeFunc free);
+
+gboolean
+gutil_idle_queue_contains_tag(
+ GUtilIdleQueue* queue,
+ GUtilIdleQueueTag tag);
+
+gboolean
+gutil_idle_queue_cancel_tag(
+ GUtilIdleQueue* queue,
+ GUtilIdleQueueTag tag);
+
+void
+gutil_idle_queue_cancel_all(
+ GUtilIdleQueue* queue);
+
+G_END_DECLS
+
+#endif /* GUTIL_IDLEQUEUE_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_inotify.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -37,7 +37,6 @@
G_BEGIN_DECLS
-typedef struct gutil_inotify_watch GUtilInotifyWatch;
typedef struct gutil_inotify_watch_callback GUtilInotifyWatchCallback;
typedef void
@@ -48,11 +47,6 @@
const char* name,
void* arg);
-GType gutil_inotify_watch_get_type();
-#define GUTIL_INOTIFY_WATCH_TYPE (gutil_inotify_watch_get_type())
-#define GUTIL_INOTIFY_WATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- GUTIL_INOTIFY_WATCH_TYPE, GUtilInotifyWatch))
-
GUtilInotifyWatch*
gutil_inotify_watch_new(
const char* path,
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_intarray.h
^
|
@@ -0,0 +1,186 @@
+/*
+ * 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 GUTIL_INTARRAY_H
+#define GUTIL_INTARRAY_H
+
+#include "gutil_types.h"
+
+G_BEGIN_DECLS
+
+/*
+ * This is basically a GArray providing better type safety at compile time.
+ */
+struct gutil_int_array {
+ int* data;
+ guint count;
+};
+
+GUtilIntArray*
+gutil_int_array_new(
+ void);
+
+GUtilIntArray*
+gutil_int_array_sized_new(
+ guint reserved_count);
+
+GUtilIntArray*
+gutil_int_array_new_from_vals(
+ const int* vals,
+ guint count);
+
+GUtilIntArray*
+gutil_int_array_new_from_value(
+ int value);
+
+int*
+gutil_int_array_free(
+ GUtilIntArray* array,
+ gboolean free_data);
+
+GUtilInts*
+gutil_int_array_free_to_ints(
+ GUtilIntArray* array);
+
+GUtilIntArray*
+gutil_int_array_ref(
+ GUtilIntArray* array);
+
+void
+gutil_int_array_unref(
+ GUtilIntArray* array);
+
+GUtilIntArray*
+gutil_int_array_append(
+ GUtilIntArray* array,
+ int val);
+
+GUtilIntArray*
+gutil_int_array_append_vals(
+ GUtilIntArray* array,
+ const int* vals,
+ guint count);
+
+GUtilIntArray*
+gutil_int_array_prepend(
+ GUtilIntArray* array,
+ int val);
+
+GUtilIntArray*
+gutil_int_array_prepend_vals(
+ GUtilIntArray* array,
+ const int* vals,
+ guint count);
+
+GUtilIntArray*
+gutil_int_array_insert(
+ GUtilIntArray* array,
+ guint pos,
+ int val);
+
+GUtilIntArray*
+gutil_int_array_insert_vals(
+ GUtilIntArray* array,
+ guint pos,
+ const int* vals,
+ guint count);
+
+GUtilIntArray*
+gutil_int_array_set_count(
+ GUtilIntArray* array,
+ guint count);
+
+int
+gutil_int_array_find(
+ GUtilIntArray* array,
+ int value);
+
+gboolean
+gutil_int_array_contains(
+ GUtilIntArray* array,
+ int value);
+
+gboolean
+gutil_int_array_remove(
+ GUtilIntArray* array,
+ int value);
+
+gboolean
+gutil_int_array_remove_fast(
+ GUtilIntArray* array,
+ int value);
+
+guint
+gutil_int_array_remove_all(
+ GUtilIntArray* array,
+ int value);
+
+guint
+gutil_int_array_remove_all_fast(
+ GUtilIntArray* array,
+ int value);
+
+GUtilIntArray*
+gutil_int_array_remove_index(
+ GUtilIntArray* array,
+ guint pos);
+
+GUtilIntArray*
+gutil_int_array_remove_index_fast(
+ GUtilIntArray* array,
+ guint pos);
+
+GUtilIntArray*
+gutil_int_array_remove_range(
+ GUtilIntArray* array,
+ guint pos,
+ guint count);
+
+void
+gutil_int_array_sort_ascending(
+ GUtilIntArray* array);
+
+void
+gutil_int_array_sort_descending(
+ GUtilIntArray* array);
+
+G_END_DECLS
+
+#endif /* GUTIL_INTARRAY_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_ints.h
^
|
@@ -0,0 +1,129 @@
+/*
+ * 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 GUTIL_INTS_H
+#define GUTIL_INTS_H
+
+#include "gutil_types.h"
+
+G_BEGIN_DECLS
+
+/*
+ * A read-only non-empty array of ints. NULL is the empty array.
+ * If it's not NULL then it's not empty.
+ */
+
+GUtilInts*
+gutil_ints_new(
+ const int* data,
+ guint count);
+
+GUtilInts*
+gutil_ints_new_take(
+ int* data,
+ guint count);
+
+GUtilInts*
+gutil_ints_new_static(
+ const int* data,
+ guint count);
+
+GUtilInts*
+gutil_ints_new_with_free_func(
+ const int* data,
+ guint count,
+ GDestroyNotify free_func,
+ gpointer user_data);
+
+GUtilInts*
+gutil_ints_new_from_ints(
+ GUtilInts* ints,
+ guint offset,
+ guint count);
+
+GUtilInts*
+gutil_ints_ref(
+ GUtilInts* ints);
+
+void
+gutil_ints_unref(
+ GUtilInts* ints);
+
+int*
+gutil_ints_unref_to_data(
+ GUtilInts* ints,
+ guint* count);
+
+const int*
+gutil_ints_get_data(
+ GUtilInts* ints,
+ guint* count);
+
+guint
+gutil_ints_get_count(
+ GUtilInts* ints);
+
+int
+gutil_ints_find(
+ GUtilInts* ints,
+ int value);
+
+gboolean
+gutil_ints_contains(
+ GUtilInts* ints,
+ int value);
+
+guint
+gutil_ints_hash(
+ gconstpointer ints);
+
+gboolean
+gutil_ints_equal(
+ gconstpointer a,
+ gconstpointer b);
+
+gint
+gutil_ints_compare(
+ gconstpointer a,
+ gconstpointer b);
+
+G_END_DECLS
+
+#endif /* GUTIL_INTS_H */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_misc.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -43,6 +43,26 @@
gulong *ids,
int count);
+void*
+gutil_hex2bin(
+ const char* str,
+ gssize len,
+ void* data);
+
+GBytes*
+gutil_hex2bytes(
+ const char* str,
+ gssize len);
+
+#define GUTIL_HEXDUMP_BUFSIZE (70)
+#define GUTIL_HEXDUMP_MAXBYTES (16)
+
+guint
+gutil_hexdump(
+ char* buf,
+ const void* data,
+ guint len); /* since 1.0.29 */
+
G_END_DECLS
#endif /* GUTIL_MISC_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_ring.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -45,7 +45,6 @@
* frees the elements it removes internally in gutil_ring_clear,
* gutil_ring_drop functions and the last gutil_ring_unref.
*/
-typedef struct gutil_ring GUtilRing;
#define GUTIL_RING_UNLIMITED_SIZE (-1)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_strv.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -102,6 +102,13 @@
GStrV* sv,
gboolean ascending);
+/**
+ * Removes leading and trailing whitespaces from all strings in the vector.
+ */
+GStrV*
+gutil_strv_strip(
+ GStrV* sv);
+
G_END_DECLS
#endif /* GUTIL_STRV_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_timenotify.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -37,18 +37,11 @@
G_BEGIN_DECLS
-typedef struct gutil_time_notify GUtilTimeNotify;
-
typedef void
(*GUtilTimeNotifyFunc)(
GUtilTimeNotify* notify,
void* arg);
-GType gutil_time_notify_get_type();
-#define GUTIL_TIME_NOTIFY_TYPE (gutil_time_notify_get_type())
-#define GUTIL_TIME_NOTIFY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
- GUTIL_TIME_NOTIFY_TYPE, GUtilTimeNotify))
-
GUtilTimeNotify*
gutil_time_notify_new(
void);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/include/gutil_types.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -34,15 +34,26 @@
#define GUTIL_TYPES_H
#include <glib.h>
-#include <glib-object.h>
#include <string.h>
#include <stdio.h>
+G_BEGIN_DECLS
+
typedef char* GStrV;
+typedef struct gutil_idle_pool GUtilIdlePool;
+typedef struct gutil_idle_queue GUtilIdleQueue;
+typedef struct gutil_ints GUtilInts;
+typedef struct gutil_int_array GUtilIntArray;
+typedef struct gutil_int_history GUtilIntHistory;
+typedef struct gutil_inotify_watch GUtilInotifyWatch;
+typedef struct gutil_ring GUtilRing;
+typedef struct gutil_time_notify GUtilTimeNotify;
#define GLOG_MODULE_DECL(m) extern GLogModule m;
typedef struct glog_module GLogModule;
+G_END_DECLS
+
#endif /* GUTIL_TYPES_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/libglibutil.dsp
^
|
@@ -87,10 +87,26 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\src\gutil_history.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\gutil_idlepool.c
# End Source File
# Begin Source File
+SOURCE=.\src\gutil_idlequeue.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\gutil_intarray.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\gutil_ints.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\gutil_log.c
# End Source File
# Begin Source File
@@ -111,10 +127,26 @@
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=.\include\gutil_history.h
+# End Source File
+# Begin Source File
+
SOURCE=.\include\gutil_idlepool.h
# End Source File
# Begin Source File
+SOURCE=.\include\gutil_idlequeue.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\gutil_intarray.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\gutil_ints.h
+# End Source File
+# Begin Source File
+
SOURCE=.\include\gutil_log.h
# End Source File
# Begin Source File
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/rpm/libglibutil.spec
^
|
@@ -1,5 +1,5 @@
Name: libglibutil
-Version: 1.0.17
+Version: 1.0.29
Release: 0
Summary: Library of glib utilities
Group: Development/Libraries
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_history.c
^
|
@@ -0,0 +1,247 @@
+/*
+ * 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 "gutil_history.h"
+#include "gutil_log.h"
+
+#define GUTIL_HISTORY_DEFAULT_TIME_FUNC g_get_monotonic_time
+
+typedef struct gutil_int_history_entry {
+ gint64 time;
+ int value;
+} GUtilIntHistoryEntry;
+
+struct gutil_int_history {
+ gint ref_count;
+ GUtilHistoryTimeFunc time;
+ gint64 max_interval;
+ int first; /* Oldest position (inclusive) */
+ int last; /* Latest position (inclusive) */
+ int max_size; /* Number of entries */
+ GUtilIntHistoryEntry entry[1];
+};
+
+GUtilIntHistory*
+gutil_int_history_new(
+ int max_size,
+ gint64 max_interval)
+{
+ return gutil_int_history_new_full(max_size, max_interval, NULL);
+}
+
+GUtilIntHistory*
+gutil_int_history_new_full(
+ int max_size,
+ gint64 max_interval,
+ GUtilHistoryTimeFunc fn)
+{
+ if (max_size > 0 && max_interval > 0) {
+ /*
+ * We don't allow to dynamically change the maximum history size
+ * so we can allocate the whole thing from a single memory block.
+ */
+ GUtilIntHistory* h = g_malloc0(sizeof(GUtilIntHistory) +
+ (max_size-1)*sizeof(GUtilIntHistoryEntry));
+ h->ref_count = 1;
+ h->max_size = max_size;
+ h->max_interval = max_interval;
+ h->first = h->last = -1;
+ h->time = fn ? fn : GUTIL_HISTORY_DEFAULT_TIME_FUNC;
+ return h;
+ }
+ return NULL;
+}
+
+GUtilIntHistory*
+gutil_int_history_ref(
+ GUtilIntHistory* h)
+{
+ if (G_LIKELY(h)) {
+ GASSERT(h->ref_count > 0);
+ g_atomic_int_inc(&h->ref_count);
+ }
+ return h;
+}
+
+void
+gutil_int_history_unref(
+ GUtilIntHistory* h)
+{
+ if (G_LIKELY(h)) {
+ GASSERT(h->ref_count > 0);
+ if (g_atomic_int_dec_and_test(&h->ref_count)) {
+ g_free(h);
+ }
+ }
+}
+
+static
+gboolean
+gutil_int_history_flush(
+ GUtilIntHistory* h,
+ const gint64 now)
+{
+ const gint64 cutoff = now - h->max_interval;
+ if (h->entry[h->last].time >= cutoff) {
+ /* At least the last entry is valid */
+ while (h->entry[h->first].time < cutoff) {
+ h->first = (h->first + 1) % h->max_size;
+ }
+ return TRUE;
+ } else {
+ /* The last entry has expired */
+ h->last = h->first = -1;
+ return FALSE;
+ }
+}
+
+guint
+gutil_int_history_size(
+ GUtilIntHistory* h)
+{
+ if (G_LIKELY(h) && h->last >= 0) {
+ if (gutil_int_history_flush(h, h->time())) {
+ if (h->first > h->last) {
+ return (h->max_size + h->last - h->first + 1);
+ } else {
+ GASSERT(h->last > h->first);
+ return (h->last - h->first + 1);
+ }
+ }
+ }
+ return 0;
+}
+
+gint64
+gutil_int_history_interval(
+ GUtilIntHistory* h)
+{
+ if (G_LIKELY(h) && h->last >= 0) {
+ const gint64 now = h->time();
+ if (gutil_int_history_flush(h, now)) {
+ return now - h->entry[h->first].time;
+ }
+ }
+ return 0;
+}
+
+void
+gutil_int_history_clear(
+ GUtilIntHistory* h)
+{
+ if (G_LIKELY(h)) {
+ h->last = h->first = -1;
+ }
+}
+
+
+static
+int
+gutil_int_history_median_at(
+ GUtilIntHistory* h,
+ const gint64 now)
+{
+ /* The caller has already checked that the history is not empty */
+ if (h->first == h->last) {
+ return h->entry[h->last].value;
+ } else {
+ int pos = h->first;
+ int v = h->entry[pos].value;
+ gint64 t = h->entry[pos].time;
+ gint64 dt = 0;
+ gint64 area = 0;
+ while (pos != h->last) {
+ gint64 t1;
+ int v1;
+ pos = (pos + 1) % h->max_size;
+ t1 = h->entry[pos].time;
+ v1 = h->entry[pos].value;
+ dt += t1 - t;
+ area += (t1 - t)*(v + v1)/2;
+ t = t1;
+ v = v1;
+ }
+ /* Integral area divided by time */
+ return (int)(area/dt);
+ }
+}
+
+int
+gutil_int_history_add(
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_idlepool.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -33,6 +33,8 @@
#include <gutil_idlepool.h>
#include <gutil_log.h>
+#include <glib-object.h>
+
typedef struct gutil_idle_pool_item GUtilIdlePoolItem;
struct gutil_idle_pool_item {
@@ -42,19 +44,42 @@
};
struct gutil_idle_pool {
- GObject object;
+ gint ref_count;
guint idle_id;
GUtilIdlePoolItem* first;
GUtilIdlePoolItem* last;
+ GUtilIdlePool** shared;
};
-typedef GObjectClass GUtilIdlePoolClass;
-G_DEFINE_TYPE(GUtilIdlePool, gutil_idle_pool, G_TYPE_OBJECT)
-
GUtilIdlePool*
gutil_idle_pool_new()
{
- return g_object_new(GUTIL_IDLE_POOL_TYPE, NULL);
+ GUtilIdlePool* self = g_slice_new0(GUtilIdlePool);
+ self->ref_count = 1;
+ return self;
+}
+
+GUtilIdlePool*
+gutil_idle_pool_get(
+ GUtilIdlePool** shared)
+{
+ if (shared) {
+ if (*shared) {
+ /* The object already exists */
+ return *shared;
+ } else {
+ GUtilIdlePool* pool = gutil_idle_pool_new();
+ pool->shared = shared;
+ /* New shared object will destroy itself if the caller
+ * doesn't reference it. */
+ gutil_idle_pool_add(pool, pool, (GDestroyNotify)
+ gutil_idle_pool_unref);
+ *shared = pool;
+ return pool;
+ }
+ } else {
+ return gutil_idle_pool_new();
+ }
}
GUtilIdlePool*
@@ -62,7 +87,8 @@
GUtilIdlePool* self)
{
if (G_LIKELY(self)) {
- g_object_ref(GUTIL_IDLE_POOL(self));
+ GASSERT(self->ref_count > 0);
+ g_atomic_int_inc(&self->ref_count);
}
return self;
}
@@ -72,7 +98,13 @@
GUtilIdlePool* self)
{
if (G_LIKELY(self)) {
- g_object_unref(GUTIL_IDLE_POOL(self));
+ GASSERT(self->ref_count > 0);
+ if (g_atomic_int_dec_and_test(&self->ref_count)) {
+ /* Clear pointer to the shared instance */
+ if (self->shared) *(self->shared) = NULL;
+ gutil_idle_pool_drain(self);
+ g_slice_free(GUtilIdlePool, self);
+ }
}
}
@@ -196,30 +228,6 @@
}
}
-static
-void
-gutil_idle_pool_dispose(
- GObject* object)
-{
- GUtilIdlePool* self = GUTIL_IDLE_POOL(object);
- gutil_idle_pool_drain(self);
- G_OBJECT_CLASS(gutil_idle_pool_parent_class)->dispose(object);
-}
-
-static
-void
-gutil_idle_pool_init(
- GUtilIdlePool* self)
-{
-}
-
-static
-void gutil_idle_pool_class_init(
- GUtilIdlePoolClass* klass)
-{
- G_OBJECT_CLASS(klass)->dispose = gutil_idle_pool_dispose;
-}
-
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_idlequeue.c
^
|
@@ -0,0 +1,315 @@
+/*
+ * 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 "gutil_idlequeue.h"
+#include "gutil_log.h"
+
+typedef struct gutil_idle_queue_item GUtilIdleQueueItem;
+
+struct gutil_idle_queue_item {
+ GUtilIdleQueueItem* next;
+ GUtilIdleQueueTag tag;
+ gpointer data;
+ GUtilIdleFunc run;
+ GFreeFunc destroy;
+ gboolean completed;
+};
+
+struct gutil_idle_queue {
+ gint ref_count;
+ guint source_id;
+ GUtilIdleQueueItem* first;
+ GUtilIdleQueueItem* last;
+};
+
+static
+void
+gutil_idle_queue_item_destroy(
+ GUtilIdleQueueItem* item)
+{
+ GASSERT(item->completed);
+ if (item->destroy) {
+ item->destroy(item->data);
+ }
+ g_slice_free(GUtilIdleQueueItem, item);
+}
+
+static
+gboolean
+gutil_idle_queue_run(
+ gpointer data)
+{
+ GUtilIdleQueue* q = data;
+ GUtilIdleQueueItem* item;
+ GUtilIdleQueueItem* done = NULL;
+
+ /*
+ * Mark all currently existing items as as completed. Callbacks
+ * that we are about to invoke may add more items, those we are
+ * not supposed to run until the next idle loop. Also, note that
+ * callbacks may cancel some of the completed items, that's why
+ * we can't remove them from the list just yet.
+ */
+ for (item = q->first; item; item = item->next) {
+ item->completed = TRUE;
+ }
+
+ while ((item = q->first) && item->completed) {
+ /* Remove this one from the list */
+ q->first = item->next;
+ if (!q->first) {
+ q->last = NULL;
+ }
+
+ /* Place it to the "done" list */
+ item->next = done;
+ done = item;
+
+ /* Invoke the callbacks */
+ if (item->run) {
+ item->run(item->data);
+ }
+
+ if (item->destroy) {
+ item->destroy(item->data);
+ }
+ }
+
+ /* Free the completed items */
+ g_slice_free_chain(GUtilIdleQueueItem, done, next);
+
+ if (q->first) {
+ /* New callbacks have been added */
+ return G_SOURCE_CONTINUE;
+ } else {
+ q->source_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+}
+
+GUtilIdleQueue*
+gutil_idle_queue_new()
+{
+ GUtilIdleQueue* q = g_slice_new0(GUtilIdleQueue);
+ q->ref_count = 1;
+ return q;
+}
+
+void
+gutil_idle_queue_free(
+ GUtilIdleQueue* q)
+{
+ gutil_idle_queue_cancel_all(q);
+ gutil_idle_queue_unref(q);
+}
+
+GUtilIdleQueue*
+gutil_idle_queue_ref(
+ GUtilIdleQueue* q)
+{
+ if (G_LIKELY(q)) {
+ GASSERT(q->ref_count > 0);
+ g_atomic_int_inc(&q->ref_count);
+ }
+ return q;
+}
+
+void
+gutil_idle_queue_unref(
+ GUtilIdleQueue* q)
+{
+ if (G_LIKELY(q)) {
+ GASSERT(q->ref_count > 0);
+ if (g_atomic_int_dec_and_test(&q->ref_count)) {
+ gutil_idle_queue_cancel_all(q);
+ g_slice_free(GUtilIdleQueue, q);
+ }
+ }
+}
+
+void
+gutil_idle_queue_add(
+ GUtilIdleQueue* q,
+ GUtilIdleFunc run,
+ gpointer data)
+{
+ gutil_idle_queue_add_tag_full(q, 0, run, data, NULL);
+}
+
+void
+gutil_idle_queue_add_full(
+ GUtilIdleQueue* q,
+ GUtilIdleFunc run,
+ gpointer data,
+ GFreeFunc free)
+{
+ gutil_idle_queue_add_tag_full(q, 0, run, data, free);
+}
+
+void
+gutil_idle_queue_add_tag(
+ GUtilIdleQueue* q,
+ GUtilIdleQueueTag tag,
+ GUtilIdleFunc run,
+ gpointer data)
+{
+ gutil_idle_queue_add_tag_full(q, tag, run, data, NULL);
+}
+
+void
+gutil_idle_queue_add_tag_full(
+ GUtilIdleQueue* q,
+ GUtilIdleQueueTag tag,
+ GUtilIdleFunc run,
+ gpointer data,
+ GFreeFunc destroy)
+{
+ if (G_LIKELY(q)) {
+ GUtilIdleQueueItem* item = g_slice_new0(GUtilIdleQueueItem);
+
+ /* Fill the item */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_inotify.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -33,6 +33,8 @@
#include <gutil_inotify.h>
#include <gutil_log.h>
+#include <glib-object.h>
+
#include <sys/inotify.h>
#include <unistd.h>
#include <errno.h>
@@ -73,6 +75,9 @@
static guint gutil_inotify_watch_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(GUtilInotifyWatch, gutil_inotify_watch, G_TYPE_OBJECT)
+#define GUTIL_INOTIFY_WATCH_TYPE (gutil_inotify_watch_get_type())
+#define GUTIL_INOTIFY_WATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ GUTIL_INOTIFY_WATCH_TYPE, GUtilInotifyWatch))
/*==========================================================================*
* GUtilInotify
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_intarray.c
^
|
@@ -0,0 +1,348 @@
+/*
+ * 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 "gutil_intarray.h"
+#include "gutil_ints.h"
+
+G_STATIC_ASSERT(sizeof(GUtilIntArray) == sizeof(GArray));
+#define ELEMENT_SIZE (sizeof(int))
+
+GUtilIntArray*
+gutil_int_array_new()
+{
+ return (GUtilIntArray*)g_array_sized_new(FALSE, FALSE, ELEMENT_SIZE, 0);
+}
+
+GUtilIntArray*
+gutil_int_array_sized_new(
+ guint reserved)
+{
+ return (GUtilIntArray*)g_array_sized_new(FALSE, FALSE, ELEMENT_SIZE,
+ reserved * ELEMENT_SIZE);
+}
+
+GUtilIntArray*
+gutil_int_array_new_from_vals(
+ const int* vals,
+ guint count)
+{
+ GUtilIntArray* array = gutil_int_array_sized_new(count);
+ gutil_int_array_append_vals(array, vals, count);
+ return array;
+}
+
+GUtilIntArray*
+gutil_int_array_new_from_value(
+ int value)
+{
+ return gutil_int_array_new_from_vals(&value, 1);
+}
+
+int*
+gutil_int_array_free(
+ GUtilIntArray* array,
+ gboolean free_data)
+{
+ if (array) {
+ if (array->count) {
+ return (int*)g_array_free((GArray*)array, free_data);
+ } else {
+ return (int*)g_array_free((GArray*)array, TRUE);
+ }
+ } else {
+ return NULL;
+ }
+}
+
+GUtilInts*
+gutil_int_array_free_to_ints(
+ GUtilIntArray* array)
+{
+ if (array) {
+ if (array->count) {
+ guint count = array->count;
+ int* values = gutil_int_array_free(array, FALSE);
+ return gutil_ints_new_take(values, count);
+ } else {
+ gutil_int_array_free(array, TRUE);
+ }
+ }
+ return NULL;
+}
+
+GUtilIntArray*
+gutil_int_array_ref(
+ GUtilIntArray* array)
+{
+ if (array) {
+ return (GUtilIntArray*)g_array_ref((GArray*)array);
+ }
+ return NULL;
+}
+
+void
+gutil_int_array_unref(
+ GUtilIntArray* array)
+{
+ if (array) {
+ g_array_unref((GArray*)array);
+ }
+}
+
+GUtilIntArray*
+gutil_int_array_append(
+ GUtilIntArray* array,
+ int val)
+{
+ return gutil_int_array_append_vals(array, &val, 1);
+}
+
+GUtilIntArray*
+gutil_int_array_append_vals(
+ GUtilIntArray* array,
+ const int* vals,
+ guint count)
+{
+ if (array) {
+ g_array_append_vals((GArray*)array, (void*)vals, count);
+ }
+ return array;
+}
+
+GUtilIntArray*
+gutil_int_array_prepend(
+ GUtilIntArray* array,
+ int val)
+{
+ return gutil_int_array_prepend_vals(array, &val, 1);
+}
+
+GUtilIntArray*
+gutil_int_array_prepend_vals(
+ GUtilIntArray* array,
+ const int* vals,
+ guint count)
+{
+ if (array) {
+ g_array_prepend_vals((GArray*)array, (void*)vals, count);
+ }
+ return array;
+}
+
+GUtilIntArray*
+gutil_int_array_insert(
+ GUtilIntArray* array,
+ guint pos,
+ int val)
+{
+ return gutil_int_array_insert_vals(array, pos, &val, 1);
+}
+
+GUtilIntArray*
+gutil_int_array_insert_vals(
+ GUtilIntArray* array,
+ guint pos,
+ const int* vals,
+ guint count)
+{
+ if (array) {
+ g_array_insert_vals((GArray*)array, pos, (void*)vals, count);
+ }
+ return array;
+}
+
+GUtilIntArray*
+gutil_int_array_set_count(
+ GUtilIntArray* array,
+ guint count)
+{
+ if (array) {
+ g_array_set_size((GArray*)array, count);
+ }
+ return array;
+}
+
+int
+gutil_int_array_find(
+ GUtilIntArray* array,
+ int value)
+{
+ if (array) {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_ints.c
^
|
@@ -0,0 +1,302 @@
+/*
+ * 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 "gutil_intarray.h"
+#include "gutil_ints.h"
+
+struct gutil_ints {
+ const int* data;
+ guint count;
+ gint ref_count;
+ GDestroyNotify free_func;
+ gpointer user_data;
+};
+
+GUtilInts*
+gutil_ints_new(
+ const int* data,
+ guint count)
+{
+ if (data && count) {
+ return gutil_ints_new_take(g_memdup(data, count*sizeof(int)), count);
+ } else {
+ return NULL;
+ }
+}
+
+GUtilInts*
+gutil_ints_new_take(
+ int* data,
+ guint count)
+{
+ return gutil_ints_new_with_free_func(data, count, g_free, data);
+}
+
+GUtilInts*
+gutil_ints_new_static(
+ const int* data,
+ guint count)
+{
+ return gutil_ints_new_with_free_func(data, count, NULL, NULL);
+}
+
+GUtilInts*
+gutil_ints_new_with_free_func(
+ const int* data,
+ guint count,
+ GDestroyNotify free_func,
+ gpointer user_data)
+{
+ if (data && count) {
+ GUtilInts* ints = g_slice_new(GUtilInts);
+ ints->data = data;
+ ints->count = count;
+ ints->free_func = free_func;
+ ints->user_data = user_data;
+ ints->ref_count = 1;
+ return ints;
+ } else {
+ return NULL;
+ }
+}
+
+static
+void
+gutil_ints_unref1(
+ gpointer ints)
+{
+ gutil_ints_unref(ints);
+}
+
+GUtilInts*
+gutil_ints_new_from_ints(
+ GUtilInts* ints,
+ guint offset,
+ guint count)
+{
+ if (ints && offset < ints->count) {
+ guint end = offset + count;
+ if (end > ints->count) {
+ end = ints->count;
+ }
+ return gutil_ints_new_with_free_func(ints->data + offset, end - offset,
+ gutil_ints_unref1, gutil_ints_ref(ints));
+ }
+ return NULL;
+}
+
+GUtilInts*
+gutil_ints_ref(
+ GUtilInts* ints)
+{
+ if (ints) {
+ g_atomic_int_inc(&ints->ref_count);
+ return ints;
+ }
+ return NULL;
+}
+
+void
+gutil_ints_unref(
+ GUtilInts* ints)
+{
+ if (ints) {
+ if (g_atomic_int_dec_and_test(&ints->ref_count)) {
+ if (ints->free_func) {
+ ints->free_func(ints->user_data);
+ }
+ g_slice_free(GUtilInts, ints);
+ }
+ }
+}
+
+int*
+gutil_ints_unref_to_data(
+ GUtilInts* ints,
+ guint* count)
+{
+ if (ints) {
+ int* result;
+ if (count) {
+ *count = ints->count;
+ }
+ if (g_atomic_int_dec_and_test(&ints->ref_count)) {
+ if (ints->free_func == g_free) {
+ /* We can allow the caller to free the data */
+ result = (int*)ints->data;
+ } else {
+ result = g_memdup(ints->data, ints->count * sizeof(int));
+ ints->free_func(ints->user_data);
+ }
+ g_slice_free(GUtilInts, ints);
+ } else {
+ result = g_memdup(ints->data, ints->count * sizeof(int));
+ }
+ return result;
+ } else {
+ if (count) {
+ *count = 0;
+ }
+ return NULL;
+ }
+}
+
+const int*
+gutil_ints_get_data(
+ GUtilInts* ints,
+ guint* count)
+{
+ if (ints) {
+ if (count) {
+ *count = ints->count;
+ }
+ return ints->data;
+ } else {
+ if (count) {
+ *count = 0;
+ }
+ return NULL;
+ }
+}
+
+guint
+gutil_ints_get_count(
+ GUtilInts* ints)
+{
+ return ints ? ints->count : 0;
+}
+
+int
+gutil_ints_find(
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_log.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -237,13 +237,14 @@
}
if (name || prefix) {
char buf[512];
- g_vsnprintf(buf, sizeof(buf), format, va);
+ char* msg = gutil_log_format(buf, sizeof(buf), format, va);
if (!prefix) prefix = "";
if (name) {
- syslog(priority, "[%s] %s%s", name, prefix, buf);
+ syslog(priority, "[%s] %s%s", name, prefix, msg);
} else {
- syslog(priority, "%s%s", prefix, buf);
+ syslog(priority, "%s%s", prefix, msg);
}
+ if (msg != buf) g_free(msg);
} else {
vsyslog(priority, format, va);
}
@@ -362,10 +363,10 @@
const GLogModule* module,
int level)
{
- if (module && module->level == GLOG_LEVEL_INHERIT && module->parent) {
+ if (module->level == GLOG_LEVEL_INHERIT && module->parent) {
return gutil_log_enabled_r(module->parent, level);
} else {
- const int max_level = (module && module->level == GLOG_LEVEL_INHERIT) ?
+ const int max_level = (module->level == GLOG_LEVEL_INHERIT) ?
gutil_log_default.level : module->level;
return (level > GLOG_LEVEL_NONE && level <= max_level) ||
(level == GLOG_LEVEL_ALWAYS);
@@ -378,7 +379,8 @@
int level)
{
if (level != GLOG_LEVEL_NONE && gutil_log_func2) {
- return gutil_log_enabled_r(module, level);
+ return gutil_log_enabled_r(module ? module : &gutil_log_default,
+ level);
}
return FALSE;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_misc.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -32,6 +32,10 @@
#include "gutil_misc.h"
+#include <glib-object.h>
+
+#include <ctype.h>
+
void
gutil_disconnect_handlers(
gpointer instance,
@@ -49,6 +53,104 @@
}
}
+void*
+gutil_hex2bin(
+ const char* str,
+ gssize len,
+ void* data)
+{
+ if (str && data && len > 0 && !(len & 1)) {
+ gssize i;
+ guint8* ptr = data;
+ for (i=0; i<len; i+=2) {
+ static const guint8 hex[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, /* 0x30..0x37 */
+ 8, 9, 0, 0, 0, 0, 0, 0, /* 0x3a..0x3f */
+ 0,10,11,12,13,14,15, 0, /* 0x40..0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x4a..0x4f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40..0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x5a..0x5f */
+ 0,10,11,12,13,14,15 /* 0x60..0x66 */
+ };
+ const char x1 = str[i];
+ const char x2 = str[i+1];
+ if (isxdigit(x1) && isxdigit(x2)) {
+ *ptr++ = (hex[x1-0x30] << 4) + hex[x2-0x30];
+ } else {
+ return NULL;
+ }
+ }
+ return data;
+ }
+ return NULL;
+}
+
+GBytes*
+gutil_hex2bytes(
+ const char* str,
+ gssize len)
+{
+ if (str) {
+ if (len < 0) len = strlen(str);
+ if (len > 0 && !(len & 1)) {
+ void* data = g_malloc(len/2);
+ if (gutil_hex2bin(str, len, data)) {
+ return g_bytes_new_take(data, len/2);
+ }
+ g_free(data);
+ }
+ }
+ return NULL;
+}
+
+/**
+ * The caller makes sure that the destination buffer has at least
+ * GUTIL_HEXDUMP_BUFSIZE bytes available. Returns the number of
+ * bytes actually dumped (no more than GUTIL_HEXDUMP_MAXBYTES).
+ *
+ * Since 1.0.29
+ */
+guint
+gutil_hexdump(
+ char* buf,
+ const void* data,
+ guint len)
+{
+ static const char hex[] = "0123456789abcdef";
+ const guint bytes_dumped = MIN(len, GUTIL_HEXDUMP_MAXBYTES);
+ const guchar* bytes = data;
+ char* ptr = buf;
+ guint i;
+
+ for (i=0; i<GUTIL_HEXDUMP_MAXBYTES; i++) {
+ if (i > 0) {
+ *ptr++ = ' ';
+ if (i == 8) *ptr++ = ' ';
+ }
+ if (i < len) {
+ const guchar b = bytes[i];
+ *ptr++ = hex[(b >> 4) & 0xf];
+ *ptr++ = hex[b & 0xf];
+ } else {
+ *ptr++ = ' ';
+ *ptr++ = ' ';
+ }
+ }
+
+ *ptr++ = ' ';
+ *ptr++ = ' ';
+ *ptr++ = ' ';
+ *ptr++ = ' ';
+ for (i=0; i<bytes_dumped; i++) {
+ const char c = bytes[i];
+ if (i == 8) *ptr++ = ' ';
+ *ptr++ = isprint(c) ? c : '.';
+ }
+
+ *ptr++ = 0;
+ return bytes_dumped;
+}
+
/*
* Local Variables:
* mode: C
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_strv.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2016 Jolla Ltd.
+ * Copyright (C) 2014-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -201,6 +201,22 @@
}
return sv;
}
+
+/**
+ * Removes leading and trailing whitespaces from all strings in the vector.
+ */
+GStrV*
+gutil_strv_strip(
+ GStrV* sv)
+{
+ if (sv) {
+ GStrV* ptr;
+ for (ptr = sv; *ptr; ptr++) {
+ *ptr = g_strstrip(*ptr);
+ }
+ }
+ return sv;
+}
/*
* Local Variables:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/src/gutil_timenotify.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -33,6 +33,8 @@
#include "gutil_timenotify.h"
#include <gutil_log.h>
+#include <glib-object.h>
+
#include <time.h>
#include <errno.h>
#include <string.h>
@@ -61,7 +63,9 @@
typedef GObjectClass GUtilTimeNotifyClass;
G_DEFINE_TYPE(GUtilTimeNotify, gutil_time_notify, G_TYPE_OBJECT)
-#define PARENT_CLASS gutil_time_notify_parent_class
+#define GUTIL_TIME_NOTIFY_TYPE (gutil_time_notify_get_type())
+#define GUTIL_TIME_NOTIFY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
+ GUTIL_TIME_NOTIFY_TYPE, GUtilTimeNotify))
GUtilTimeNotify*
gutil_time_notify_new()
@@ -187,7 +191,7 @@
g_io_channel_shutdown(self->io_channel, FALSE, NULL);
g_io_channel_unref(self->io_channel);
}
- G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
+ G_OBJECT_CLASS(gutil_time_notify_parent_class)->finalize(object);
}
static
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/Makefile
^
|
@@ -2,8 +2,13 @@
all:
%:
+ @$(MAKE) -C test_history $*
@$(MAKE) -C test_idlepool $*
+ @$(MAKE) -C test_idlequeue $*
@$(MAKE) -C test_inotify $*
+ @$(MAKE) -C test_intarray $*
+ @$(MAKE) -C test_ints $*
+ @$(MAKE) -C test_log $*
@$(MAKE) -C test_misc $*
@$(MAKE) -C test_ring $*
@$(MAKE) -C test_strv $*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/common/Makefile
^
|
@@ -11,7 +11,7 @@
endif
SRC ?= $(EXE).c
-COMMON_SRC ?= test_main.c
+COMMON_SRC ?= test_main.c test_object.c
#
# Required packages
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/common/test_common.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -35,12 +35,19 @@
#include <gutil_types.h>
+#include <glib-object.h>
+
#define TEST_FLAG_DEBUG (0x01)
typedef struct test_opt {
int flags;
} TestOpt;
+GType test_object_get_type(void);
+#define TEST_OBJECT_TYPE (test_object_get_type())
+
+extern gint test_object_count;
+
/* Should be invoked after g_test_init */
void
test_init(
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/common/test_object.c
^
|
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 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>
+
+typedef GObject TestObject;
+typedef GObjectClass TestObjectClass;
+
+G_DEFINE_TYPE(TestObject, test_object, G_TYPE_OBJECT)
+
+gint test_object_count = 0;
+
+static
+void
+test_object_init(
+ TestObject* self)
+{
+ g_atomic_int_inc(&test_object_count);
+}
+
+static
+void
+test_object_finalize(
+ GObject* object)
+{
+ GASSERT(test_object_count > 0);
+ g_atomic_int_add(&test_object_count, -1);
+ G_OBJECT_CLASS(test_object_parent_class)->finalize(object);
+}
+
+static
+void
+test_object_class_init(
+ TestObjectClass* klass)
+{
+ klass->finalize = test_object_finalize;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/coverage/run
^
|
@@ -3,7 +3,18 @@
# This script requires lcov to be installed
#
-TESTS="test_idlepool test_inotify test_misc test_ring test_strv"
+TESTS="\
+test_history \
+test_idlepool \
+test_idlequeue \
+test_inotify \
+test_intarray \
+test_ints \
+test_log \
+test_misc \
+test_ring \
+test_strv"
+
FLAVOR="release"
pushd `dirname $0` > /dev/null
@@ -35,4 +46,4 @@
rm -f "$FULL_COV" "$GLIBUTIL_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 "$GLIBUTIL_COV" || exit 1
-genhtml $GENHTML_OPT "$GLIBUTIL_COV" --output-directory "$COV_DIR/results" || exit 1
+genhtml $GENHTML_OPT -t libglibutil "$GLIBUTIL_COV" --output-directory "$COV_DIR/results" || exit 1
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/libglibutil_test.dsw
^
|
@@ -15,10 +15,70 @@
###############################################################################
+Project: "test_history"=.\test_history\test_history.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libglibutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "test_idlepool"=.\test_idlepool\test_idlepool.dsp - Package Owner=<4>
Package=<5>
{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libglibutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "test_idlequeue"=.\test_idlequeue\test_idlequeue.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libglibutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "test_intarray"=.\test_intarray\test_intarray.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libglibutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "test_ints"=.\test_ints\test_ints.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
}}}
Package=<4>
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_history/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_history
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_history/test_history.c
^
|
@@ -0,0 +1,300 @@
+/*
+ * 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 "gutil_history.h"
+
+static TestOpt test_opt;
+static gint64 test_history_time;
+
+static
+gint64
+test_history_time_func(void)
+{
+ return test_history_time;
+}
+
+/*==========================================================================*
+ * NULL tolerance
+ *==========================================================================*/
+
+static
+void
+test_history_null(
+ void)
+{
+ gutil_int_history_unref(NULL);
+ gutil_int_history_clear(NULL);
+ g_assert(!gutil_int_history_ref(NULL));
+ g_assert(!gutil_int_history_size(NULL));
+ g_assert(!gutil_int_history_interval(NULL));
+ g_assert(!gutil_int_history_add(NULL, 1));
+ g_assert(!gutil_int_history_median(NULL, 0));
+ g_assert(!gutil_int_history_new(0, 0));
+ g_assert(!gutil_int_history_new(1, 0));
+ g_assert(!gutil_int_history_new(0, 1));
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_history_basic(
+ void)
+{
+ /* The default time functon returns real time, not usable for testing */
+ GUtilIntHistory* h = gutil_int_history_new(1, 1);
+ g_assert(gutil_int_history_size(h) == 0);
+ g_assert(gutil_int_history_interval(h) == 0);
+ gutil_int_history_unref(gutil_int_history_ref(h));
+ gutil_int_history_unref(h);
+}
+
+/*==========================================================================*
+ * Clear
+ *==========================================================================*/
+
+static
+void
+test_history_clear(
+ void)
+{
+ GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
+ test_history_time_func);
+ g_assert(gutil_int_history_median(h, 0) == 0);
+ test_history_time = 2;
+ g_assert(gutil_int_history_add(h, 1) == 1);
+ /* Time hasn't changed, 1 is replaced with 2 */
+ g_assert(gutil_int_history_add(h, 2) == 2);
+ /* Time goes back, 2 is replaced with 3 */
+ test_history_time -=1;
+ g_assert(gutil_int_history_add(h, 3) == 3);
+ test_history_time += 2;
+ g_assert(gutil_int_history_add(h, 5) == 4);
+ g_assert(gutil_int_history_size(h) == 2);
+ g_assert(gutil_int_history_median(h, 0) == 4);
+ g_assert(gutil_int_history_interval(h) == 1);
+ gutil_int_history_clear(h);
+ g_assert(!gutil_int_history_size(h));
+ g_assert(!gutil_int_history_interval(h));
+ gutil_int_history_unref(h);
+}
+
+/*==========================================================================*
+ * Median
+ *==========================================================================*/
+
+static
+void
+test_history_median(
+ void)
+{
+ GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
+ test_history_time_func);
+ test_history_time = 1;
+ g_assert(gutil_int_history_add(h, 1) == 1);
+ test_history_time += 1;
+ g_assert(gutil_int_history_add(h, 5) == 3);
+ test_history_time += 1;
+ /* Still the same, both ends of the interval are inclusive */
+ g_assert(gutil_int_history_median(h, 0) == 3);
+ test_history_time += 1;
+ /* Now one entry expires */
+ g_assert(gutil_int_history_median(h, 0) == 5);
+ test_history_time += 1;
+ /* The last one expires too */
+ g_assert(gutil_int_history_median(h, 0) == 0);
+ gutil_int_history_unref(h);
+}
+
+/*==========================================================================*
+ * Size
+ *==========================================================================*/
+
+static
+void
+test_history_size(
+ void)
+{
+ GUtilIntHistory* h = gutil_int_history_new_full(2, 2,
+ test_history_time_func);
+ test_history_time = 1;
+ g_assert(gutil_int_history_add(h, 1) == 1);
+ test_history_time += 1;
+ g_assert(gutil_int_history_add(h, 5) == 3);
+ g_assert(gutil_int_history_size(h) == 2);
+ test_history_time += 1;
+ /* Still the same, both ends of the interval are inclusive */
+ g_assert(gutil_int_history_size(h) == 2);
+ test_history_time += 1;
+ /* Now one entry expires */
+ g_assert(gutil_int_history_size(h) == 1);
+ test_history_time += 1;
+ /* The last one expires too */
+ g_assert(gutil_int_history_size(h) == 0);
+ gutil_int_history_unref(h);
+}
+
+/*==========================================================================*
+ * Interval
+ *==========================================================================*/
+
+static
+void
+test_history_interval(
+ void)
+{
+ GUtilIntHistory* h = gutil_int_history_new_full(2, 3,
+ test_history_time_func);
+ test_history_time = 1;
+ g_assert(gutil_int_history_add(h, 1) == 1);
+ test_history_time += 1;
+ g_assert(gutil_int_history_add(h, 5) == 3);
+ g_assert(gutil_int_history_interval(h) == 1);
+ test_history_time += 1;
+ /* Both ends of the interval are inclusive */
+ g_assert(gutil_int_history_interval(h) == 2);
+ test_history_time += 2;
+ /* Now one entry with timestamp 1 expires, the one remaining has
+ * timestamp 2, the current time is 5 so the interval becomes 3 */
+ g_assert(gutil_int_history_interval(h) == 3);
+ test_history_time += 1;
+ /* The last one expires too */
+ g_assert(gutil_int_history_interval(h) == 0);
+ gutil_int_history_unref(h);
+}
+
+/*==========================================================================*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_history/test_history.dsp
^
|
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="test_history" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=test_history - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "test_history.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "test_history.mak" CFG="test_history - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "test_history - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_history - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "test_history - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "build/release"
+# PROP BASE Intermediate_Dir "build/release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "build/release"
+# PROP Intermediate_Dir "build/release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /machine:I386 /libpath:"$(GTK_ROOT)/lib"
+
+!ELSEIF "$(CFG)" == "test_history - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "build/debug"
+# PROP BASE Intermediate_Dir "build/debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "build/debug"
+# PROP Intermediate_Dir "build/debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"$(GTK_ROOT)/lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "test_history - Win32 Release"
+# Name "test_history - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\common\test_main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_history.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\common\test_common.h
+# End Source File
+# End Group
+# End Target
+# End Project
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_idlepool/test_idlepool.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -39,29 +39,35 @@
static TestOpt test_opt;
+static
+gboolean
+test_timeout(
+ gpointer loop)
+{
+ g_assert(!"TIMEOUT");
+ return G_SOURCE_REMOVE;
+}
+
+static
+void
+test_done(
+ gpointer loop)
+{
+ g_main_loop_quit(loop);
+}
+
/*==========================================================================*
* Basic
*==========================================================================*/
typedef struct test_basic {
- GMainLoop* loop;
GUtilIdlePool* pool;
- guint timeout_id;
gboolean array_free_count;
gboolean ok;
} TestBasic;
static
void
-test_basic_done(
- gpointer param)
-{
- TestBasic* test = param;
- g_main_loop_quit(test->loop);
-}
-
-static
-void
test_basic_array_free(
gpointer param)
{
@@ -100,34 +106,21 @@
}
static
-gboolean
-test_basic_timeout(
- gpointer param)
-{
- TestBasic* test = param;
- GERR("TIMEOUT");
- test->timeout_id = 0;
- g_main_loop_quit(test->loop);
- return G_SOURCE_REMOVE;
-}
-
-static
void
test_basic(
void)
{
GPtrArray* array = g_ptr_array_new_with_free_func(test_basic_array_free);
GVariant* variant = g_variant_take_ref(g_variant_new_int32(1));
- GObject* object = g_object_new(GUTIL_IDLE_POOL_TYPE, NULL);
+ GObject* object = g_object_new(TEST_OBJECT_TYPE, NULL);
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
TestBasic test;
memset(&test, 0, sizeof(test));
- test.loop = g_main_loop_new(NULL, TRUE);
test.pool = gutil_idle_pool_new();
if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- test.timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
- test_basic_timeout, &test);
+ g_timeout_add_seconds(TEST_TIMEOUT, test_timeout, loop);
}
/* These have no effect, just testing NULL-telerance */
@@ -159,18 +152,44 @@
g_object_unref(object);
gutil_idle_pool_ref(test.pool);
gutil_idle_pool_add(test.pool, &test, test_basic_unref_pool);
- gutil_idle_pool_add(test.pool, &test, test_basic_done);
- g_main_loop_run(test.loop);
+ 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);
g_assert(test.ok);
+ g_assert(!test_object_count);
+ g_main_loop_unref(loop);
+}
+
+/*==========================================================================*
+ * Shared
+ *==========================================================================*/
+
+static
+void
+test_shared(
+ void)
+{
+ GUtilIdlePool* shared = NULL;
+ GUtilIdlePool* pool = gutil_idle_pool_get(&shared);
+ GUtilIdlePool* pool2 = gutil_idle_pool_get(NULL);
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+
+ g_assert(shared == pool);
+ g_assert(gutil_idle_pool_get(&shared) == pool);
+ g_assert(pool2 != pool);
+
if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- g_assert(test.timeout_id);
- g_source_remove(test.timeout_id);
+ g_timeout_add_seconds(TEST_TIMEOUT, test_timeout, loop);
}
- g_main_loop_unref(test.loop);
+ /* The pool invokes the callback and destroys itself */
+ gutil_idle_pool_add(pool, loop, test_done);
+ g_main_loop_run(loop);
+ g_assert(!shared);
+ gutil_idle_pool_unref(pool2);
+ g_main_loop_unref(loop);
}
/*==========================================================================*
@@ -186,6 +205,7 @@
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);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_idlepool/test_idlepool.dsp
^
|
@@ -87,11 +87,15 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\test_idlepool.c
+# End Source File
+# Begin Source File
+
SOURCE=..\common\test_main.c
# End Source File
# Begin Source File
-SOURCE=.\test_idlepool.c
+SOURCE=..\common\test_object.c
# End Source File
# End Group
# Begin Group "Header Files"
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_idlequeue/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_idlequeue
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_idlequeue/test_idlequeue.c
^
|
@@ -0,0 +1,294 @@
+/*
+ * 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 "gutil_idlequeue.h"
+#include "gutil_log.h"
+
+#define TEST_TIMEOUT (10) /* seconds */
+
+static TestOpt test_opt;
+
+static
+void
+test_idlequeue_noooo(
+ gpointer param)
+{
+ g_assert(!"NOOO!!!");
+}
+
+static
+gboolean
+test_idlequeue_timeout(
+ gpointer param)
+{
+ g_assert(!"TIMEOUT");
+ return G_SOURCE_REMOVE;
+}
+
+static
+void
+test_idlequeue_loop_quit(
+ gpointer loop)
+{
+ g_main_loop_quit(loop);
+}
+
+static
+void
+test_idlequeue_int_inc(
+ gpointer data)
+{
+ int* ptr = data;
+ (*ptr)++;
+}
+
+/*==========================================================================*
+ * Null
+ *==========================================================================*/
+
+static
+void
+test_idlequeue_null(
+ void)
+{
+ /* Test NULL tolerance */
+ int i = 0;
+ g_assert(!gutil_idle_queue_ref(NULL));
+ gutil_idle_queue_unref(NULL);
+ gutil_idle_queue_free(NULL);
+ g_assert(!gutil_idle_queue_contains_tag(NULL, 0));
+ g_assert(!gutil_idle_queue_cancel_tag(NULL, 0));
+ gutil_idle_queue_cancel_all(NULL);
+ gutil_idle_queue_add(NULL, NULL, NULL);
+ gutil_idle_queue_add_full(NULL, NULL, NULL, NULL);
+ gutil_idle_queue_add_tag(NULL, 0, NULL, NULL);
+ gutil_idle_queue_add_tag_full(NULL, 0, NULL, NULL, NULL);
+ /* IF queue is NULL, the destroy function gets invoked immediately: */
+ gutil_idle_queue_add_tag_full(NULL, 0, NULL, &i, test_idlequeue_int_inc);
+ g_assert(i == 1);
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_idlequeue_basic(
+ void)
+{
+ guint timeout_id = 0;
+ int count = 0;
+ GUtilIdleQueue* q = gutil_idle_queue_new();
+ GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+
+ gutil_idle_queue_unref(gutil_idle_queue_ref(q));
+ gutil_idle_queue_add_tag_full(q, 1, test_idlequeue_int_inc, &count, NULL);
+ gutil_idle_queue_add_tag_full(q, 2, NULL, &count, test_idlequeue_int_inc);
+ gutil_idle_queue_add_tag_full(q, 3, test_idlequeue_loop_quit, loop, NULL);
+ g_assert(!gutil_idle_queue_contains_tag(q, 0));
+ g_assert(gutil_idle_queue_contains_tag(q, 1));
+ g_assert(gutil_idle_queue_contains_tag(q, 2));
+ g_assert(gutil_idle_queue_contains_tag(q, 3));
+
+ if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
+ timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
+ test_idlequeue_timeout, NULL);
+ }
+
+ g_main_loop_run(loop);
+ g_assert(count == 2);
+
+ if (timeout_id) {
+ g_source_remove(timeout_id);
+ }
+
+ gutil_idle_queue_unref(q);
+ g_main_loop_unref(loop);
+}
+/*==========================================================================*
+ * Add
+ *==========================================================================*/
+
+typedef struct test_idlequeue_add_data {
+ GUtilIdleQueue* q;
+ GMainLoop* loop;
+} TestAdd;
+
+static
+void
+test_idlequeue_add_cb(
+ gpointer data)
+{
+ /* Adding new item from the callback */
+ TestAdd* test = data;
+ gutil_idle_queue_add(test->q, test_idlequeue_loop_quit, test->loop);
+}
+
+static
+void
+test_idlequeue_add(
+ void)
+{
+ guint timeout_id = 0;
+ TestAdd test;
+
+ test.q = gutil_idle_queue_new();
+ test.loop = g_main_loop_new(NULL, TRUE);
+
+ if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
+ timeout_id = g_timeout_add_seconds(TEST_TIMEOUT,
+ test_idlequeue_timeout, NULL);
+ }
+
+ gutil_idle_queue_add(test.q, test_idlequeue_add_cb, &test);
+ g_main_loop_run(test.loop);
+
+ if (timeout_id) {
+ g_source_remove(timeout_id);
+ }
+
+ gutil_idle_queue_unref(test.q);
+ g_main_loop_unref(test.loop);
+}
+
+/*==========================================================================*
+ * Cancel
+ *==========================================================================*/
+
+static
+void
+test_idlequeue_cancel(
+ void)
+{
+ int count = 0;
+ GUtilIdleQueue* q = gutil_idle_queue_new();
+
+ /* Destroying the queue cancels the callbacks */
+ gutil_idle_queue_add(q, test_idlequeue_int_inc, &count);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_idlequeue/test_idlequeue.dsp
^
|
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="test_idlequeue" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=test_idlequeue - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "test_idlequeue.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "test_idlequeue.mak" CFG="test_idlequeue - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "test_idlequeue - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_idlequeue - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "test_idlequeue - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "build/release"
+# PROP BASE Intermediate_Dir "build/release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "build/release"
+# PROP Intermediate_Dir "build/release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winsqueue.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winsqueue.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /machine:I386 /libpath:"$(GTK_ROOT)/lib"
+
+!ELSEIF "$(CFG)" == "test_idlequeue - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "build/debug"
+# PROP BASE Intermediate_Dir "build/debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "build/debug"
+# PROP Intermediate_Dir "build/debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winsqueue.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winsqueue.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"$(GTK_ROOT)/lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "test_idlequeue - Win32 Release"
+# Name "test_idlequeue - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\common\test_main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_idlequeue.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\common\test_common.h
+# End Source File
+# End Group
+# End Target
+# End Project
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_intarray/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_intarray
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_intarray/test_intarray.c
^
|
@@ -0,0 +1,325 @@
+/*
+ * 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 "gutil_intarray.h"
+#include "gutil_ints.h"
+
+static TestOpt test_opt;
+
+/*==========================================================================*
+ * NULL tolerance
+ *==========================================================================*/
+
+static
+void
+test_intarray_null(
+ void)
+{
+ gutil_int_array_unref(NULL);
+ g_assert(!gutil_int_array_ref(NULL));
+ g_assert(!gutil_int_array_free(NULL, FALSE));
+ g_assert(!gutil_int_array_free_to_ints(NULL));
+ g_assert(!gutil_int_array_append(NULL, 0));
+ g_assert(!gutil_int_array_append_vals(NULL, NULL, 0));
+ g_assert(!gutil_int_array_prepend(NULL, 0));
+ g_assert(!gutil_int_array_prepend_vals(NULL, NULL, 0));
+ g_assert(!gutil_int_array_insert(NULL, 0, 0));
+ g_assert(!gutil_int_array_insert_vals(NULL, 0, NULL, 0));
+ g_assert(gutil_int_array_find(NULL, 0) == -1);
+ g_assert(!gutil_int_array_contains(NULL, 0));
+ g_assert(!gutil_int_array_remove(NULL, 0));
+ g_assert(!gutil_int_array_remove_fast(NULL, 0));
+ g_assert(!gutil_int_array_remove_all(NULL, 0));
+ g_assert(!gutil_int_array_remove_all_fast(NULL, 0));
+ g_assert(!gutil_int_array_set_count(NULL, 0));
+ g_assert(!gutil_int_array_remove_index(NULL, 0));
+ g_assert(!gutil_int_array_remove_index_fast(NULL, 0));
+ g_assert(!gutil_int_array_remove_range(NULL, 0, 0));
+ gutil_int_array_sort_ascending(NULL);
+ gutil_int_array_sort_descending(NULL);
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_intarray_basic(
+ void)
+{
+ static const int vals[] = { 0, 1, 2 };
+ GUtilIntArray* a = gutil_int_array_new();
+ GUtilInts* ints;
+
+ g_assert(gutil_int_array_append(a, 0) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ g_assert(gutil_int_array_append(a, 1) == a);
+ g_assert(a->count == 2);
+ g_assert(a->data[0] == 0);
+ g_assert(a->data[1] == 1);
+
+ g_assert(gutil_int_array_prepend(a, 2) == a);
+ g_assert(a->count == 3);
+ g_assert(a->data[0] == 2);
+ g_assert(a->data[1] == 0);
+ g_assert(a->data[2] == 1);
+
+ gutil_int_array_sort_ascending(a);
+ g_assert(a->data[0] == 0);
+ g_assert(a->data[1] == 1);
+ g_assert(a->data[2] == 2);
+
+ gutil_int_array_sort_descending(a);
+ g_assert(a->data[0] == 2);
+ g_assert(a->data[1] == 1);
+ g_assert(a->data[2] == 0);
+
+ g_assert(gutil_int_array_remove_index_fast(a, 0) == a);
+ g_assert(a->count == 2);
+ g_assert(a->data[0] == 0);
+ g_assert(a->data[1] == 1);
+
+ g_assert(gutil_int_array_remove_range(a, 1, 2) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ /* This removes nothing (position out of range) */
+ g_assert(gutil_int_array_remove_range(a, 1, 2) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ /* This too (zero count) */
+ g_assert(gutil_int_array_remove_range(a, 0, 0) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ g_assert(gutil_int_array_remove_range(a, 0, 1) == a);
+ g_assert(a->count == 0);
+
+ g_assert(gutil_int_array_insert(a, 0, 0) == a);
+ g_assert(gutil_int_array_insert(a, 0, 1) == a);
+ g_assert(a->count == 2);
+ g_assert(a->data[0] == 1);
+ g_assert(a->data[1] == 0);
+
+ g_assert(gutil_int_array_insert(a, 2, 2) == a);
+ g_assert(a->count == 3);
+ g_assert(a->data[0] == 1);
+ g_assert(a->data[1] == 0);
+ g_assert(a->data[2] == 2);
+
+ g_assert(gutil_int_array_set_count(a, 2) == a);
+ g_assert(a->count == 2);
+ g_assert(a->data[0] == 1);
+ g_assert(a->data[1] == 0);
+
+ g_assert(gutil_int_array_remove_index(a, 0) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ g_assert(gutil_int_array_remove_index(a, 1) == a);
+ g_assert(a->count == 1);
+ g_assert(a->data[0] == 0);
+
+ gutil_int_array_ref(a);
+ gutil_int_array_free(a, TRUE);
+ g_assert(!a->data);
+ g_assert(!a->count);
+ gutil_int_array_unref(a);
+
+ a = gutil_int_array_sized_new(0);
+ g_assert(!gutil_int_array_free(a, FALSE));
+
+ a = gutil_int_array_sized_new(0);
+ g_assert(!gutil_int_array_free_to_ints(a));
+
+ a = gutil_int_array_sized_new(G_N_ELEMENTS(vals));
+ g_assert(gutil_int_array_append_vals(a, vals, G_N_ELEMENTS(vals)) == a);
+ g_assert(a->count == G_N_ELEMENTS(vals));
+ g_assert(!memcmp(a->data, vals, sizeof(vals)));
+ ints = gutil_int_array_free_to_ints(a);
+ g_assert(gutil_ints_get_count(ints) == G_N_ELEMENTS(vals));
+ g_assert(!memcmp(gutil_ints_get_data(ints, NULL), vals, sizeof(vals)));
+ gutil_ints_unref(ints);
+}
+
+/*==========================================================================*
+ * Find
+ *==========================================================================*/
+
+static
+void
+test_intarray_find(
+ void)
+{
+ static const int vals[] = { 0, 1, 2 };
+ GUtilIntArray* a = gutil_int_array_new();
+
+ g_assert(gutil_int_array_append_vals(a, vals, G_N_ELEMENTS(vals)) == a);
+ g_assert(gutil_int_array_find(a, -1) == -1);
+ g_assert(gutil_int_array_find(a, 0) == 0);
+ g_assert(gutil_int_array_find(a, 1) == 1);
+ g_assert(gutil_int_array_find(a, 2) == 2);
+ g_assert(gutil_int_array_find(a, 3) == -1);
+ g_assert(gutil_int_array_contains(a, 2));
+ g_assert(!gutil_int_array_contains(a, 3));
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_intarray/test_intarray.dsp
^
|
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="test_intarray" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=test_intarray - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "test_intarray.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "test_intarray.mak" CFG="test_intarray - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "test_intarray - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_intarray - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "test_intarray - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "build/release"
+# PROP BASE Intermediate_Dir "build/release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "build/release"
+# PROP Intermediate_Dir "build/release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /machine:I386 /libpath:"$(GTK_ROOT)/lib"
+
+!ELSEIF "$(CFG)" == "test_intarray - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "build/debug"
+# PROP BASE Intermediate_Dir "build/debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "build/debug"
+# PROP Intermediate_Dir "build/debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"$(GTK_ROOT)/lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "test_intarray - Win32 Release"
+# Name "test_intarray - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\common\test_main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_intarray.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\common\test_common.h
+# End Source File
+# End Group
+# End Target
+# End Project
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_ints/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_ints
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_ints/test_ints.c
^
|
@@ -0,0 +1,221 @@
+/*
+ * 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 "gutil_ints.h"
+
+static TestOpt test_opt;
+
+/*==========================================================================*
+ * NULL tolerance
+ *==========================================================================*/
+
+static
+void
+test_ints_null(
+ void)
+{
+ int val = 0;
+ guint count;
+ gutil_ints_unref(NULL);
+ g_assert(!gutil_ints_ref(NULL));
+ g_assert(!gutil_ints_new(NULL, 0));
+ g_assert(!gutil_ints_new(NULL, 1));
+ g_assert(!gutil_ints_new(&val, 0));
+ g_assert(!gutil_ints_new_take(NULL, 0));
+ g_assert(!gutil_ints_new_take(NULL, 1));
+ g_assert(!gutil_ints_new_take(&val, 0));
+ g_assert(!gutil_ints_new_static(NULL, 0));
+ g_assert(!gutil_ints_new_static(NULL, 1));
+ g_assert(!gutil_ints_new_static(&val, 0));
+ g_assert(!gutil_ints_new_with_free_func(NULL, 0, NULL, NULL));
+ g_assert(!gutil_ints_new_with_free_func(NULL, 1, NULL, NULL));
+ g_assert(!gutil_ints_new_with_free_func(&val, 0, NULL, NULL));
+ g_assert(!gutil_ints_new_from_ints(NULL, 0, 0));
+ g_assert(!gutil_ints_hash(NULL));
+ g_assert(!gutil_ints_get_count(NULL));
+ g_assert(!gutil_ints_contains(NULL, 0));
+ g_assert(gutil_ints_find(NULL, 0) < 0);
+ count = 1;
+ g_assert(!gutil_ints_get_data(NULL, NULL));
+ g_assert(!gutil_ints_get_data(NULL, &count));
+ g_assert(!count);
+ count = 1;
+ g_assert(!gutil_ints_unref_to_data(NULL, NULL));
+ g_assert(!gutil_ints_unref_to_data(NULL, &count));
+ g_assert(!count);
+}
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static
+void
+test_custom_free(
+ gpointer data)
+{
+ g_free(data);
+}
+
+static
+void
+test_ints_basic(
+ void)
+{
+ /* First 3 elements match */
+ const int a1[] = { 1, 2, 3 };
+ const int a2[] = { 1, 2, 3, 4 };
+ int* data;
+ guint count;
+ GUtilInts* i1 = gutil_ints_new(a1, G_N_ELEMENTS(a1));
+ GUtilInts* i2 = gutil_ints_new_static(a2, G_N_ELEMENTS(a2));
+ GUtilInts* i3;
+ GUtilInts* i4;
+ g_assert(gutil_ints_get_count(i1) == G_N_ELEMENTS(a1));
+ g_assert(gutil_ints_get_count(i2) == G_N_ELEMENTS(a2));
+ g_assert(gutil_ints_get_data(i1, NULL) != a2);
+ g_assert(gutil_ints_get_data(i2, &count) == a2);
+ g_assert(count == G_N_ELEMENTS(a2));
+ g_assert(!gutil_ints_new_from_ints(i1, G_N_ELEMENTS(a2), 1));
+ i3 = gutil_ints_new_from_ints(i1, 0, G_N_ELEMENTS(a1) + 1);
+ i4 = gutil_ints_new_from_ints(i2, 0, G_N_ELEMENTS(a1));
+
+ g_assert(gutil_ints_equal(i1, i1));
+ g_assert(!gutil_ints_equal(i1, i2));
+ g_assert(gutil_ints_equal(i1, i3));
+ g_assert(gutil_ints_equal(i1, i3));
+
+ g_assert(!gutil_ints_contains(i1, 0));
+ g_assert(gutil_ints_contains(i1, 1));
+
+ g_assert(gutil_ints_find(i1, 0) < 0);
+ g_assert(gutil_ints_find(i1, 1) == 0);
+ g_assert(gutil_ints_find(i1, 2) == 1);
+
+ /* This gutil_ints_unref_to_data doesn't actually free i1 because
+ * a reference to it is held by i3: */
+ data = gutil_ints_unref_to_data(i1, &count);
+ g_assert(count == G_N_ELEMENTS(a1));
+ g_assert(!memcmp(a1, data, count*sizeof(int)));
+ g_free(data);
+
+ gutil_ints_unref(i2);
+ gutil_ints_unref(i3);
+ gutil_ints_unref(i4);
+
+ /* This gutil_ints_unref_to_data actually does free i1: */
+ i1 = gutil_ints_new(a1, G_N_ELEMENTS(a1));
+ data = gutil_ints_unref_to_data(i1, NULL);
+ g_assert(!memcmp(a1, data, G_N_ELEMENTS(a1)*sizeof(int)));
+ g_free(data);
+
+ /* And this one duplicates the data because we use test_custom_free: */
+ data = g_memdup(a1, sizeof(a1));
+ i1 = gutil_ints_new_with_free_func(data, G_N_ELEMENTS(a1),
+ test_custom_free, data);
+ data = gutil_ints_unref_to_data(i1, &count);
+ g_assert(count == G_N_ELEMENTS(a1));
+ g_assert(!memcmp(a1, data, count*sizeof(int)));
+ g_free(data);
+}
+
+/*==========================================================================*
+ * Compare
+ *==========================================================================*/
+
+static
+void
+test_ints_compare(
+ void)
+{
+ const int a1[] = { 1 };
+ const int a2[] = { 1, 2 };
+ const int a3[] = { 2 };
+ GUtilInts* i1 = gutil_ints_new_static(a1, G_N_ELEMENTS(a1));
+ GUtilInts* i2 = gutil_ints_new_static(a2, G_N_ELEMENTS(a2));
+ GUtilInts* i3 = gutil_ints_new_static(a3, G_N_ELEMENTS(a3));
+ GUtilInts* i4 = gutil_ints_new_from_ints(i1, 0, G_N_ELEMENTS(a1));
+
+ g_assert(gutil_ints_hash(i1) == 1235);
+ g_assert(gutil_ints_hash(i2) == 1239);
+
+ g_assert(gutil_ints_equal(NULL, NULL));
+ g_assert(!gutil_ints_equal(NULL, i1));
+ g_assert(!gutil_ints_equal(i1, NULL));
+ g_assert(!gutil_ints_equal(i1, i2));
+ g_assert(!gutil_ints_equal(i2, i1));
+ g_assert(!gutil_ints_equal(i1, i3));
+ g_assert(!gutil_ints_equal(i3, i1));
+ g_assert(gutil_ints_equal(i1, i4));
+ g_assert(gutil_ints_equal(i4, i1));
+
+ g_assert(gutil_ints_compare(NULL, NULL) == 0);
+ g_assert(gutil_ints_compare(NULL, i1) < 0);
+ g_assert(gutil_ints_compare(i1, NULL) > 0);
+ g_assert(gutil_ints_compare(i1, i2) < 0);
+ g_assert(gutil_ints_compare(i2, i1) > 0);
+ g_assert(gutil_ints_compare(i1, i3) < 0);
+ g_assert(gutil_ints_compare(i3, i1) > 0);
+ g_assert(gutil_ints_compare(i1, i4) == 0);
+ g_assert(gutil_ints_compare(i4, i1) == 0);
+
+ gutil_ints_unref(i1);
+ gutil_ints_unref(i2);
+ gutil_ints_unref(i3);
+ gutil_ints_unref(i4);
+}
+
+/*==========================================================================*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_ints/test_ints.dsp
^
|
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="test_ints" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=test_ints - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "test_ints.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "test_ints.mak" CFG="test_ints - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "test_ints - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "test_ints - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "test_ints - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "build/release"
+# PROP BASE Intermediate_Dir "build/release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "build/release"
+# PROP Intermediate_Dir "build/release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /machine:I386 /libpath:"$(GTK_ROOT)/lib"
+
+!ELSEIF "$(CFG)" == "test_ints - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "build/debug"
+# PROP BASE Intermediate_Dir "build/debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "build/debug"
+# PROP Intermediate_Dir "build/debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "../../include" /I "../common" /I "$(GTK_ROOT)/include/glib-2.0" /I "$(GTK_ROOT)/lib/glib-2.0/include" /D "_DEBUG" /D "DEBUG" /D "WIN32" /D "_CONSOLE" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 glib-2.0.lib gobject-2.0.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"$(GTK_ROOT)/lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "test_ints - Win32 Release"
+# Name "test_ints - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\common\test_main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_ints.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\common\test_common.h
+# End Source File
+# End Group
+# End Target
+# End Project
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_log/Makefile
^
|
@@ -0,0 +1,5 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = test_log
+
+include ../common/Makefile
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_log/test_log.c
^
|
@@ -0,0 +1,196 @@
+/*
+ * 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 "gutil_strv.h"
+#include "gutil_log.h"
+
+static TestOpt test_opt;
+
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
+static GString* test_log_basic_buf;
+
+static
+void
+test_log_basic_fn(
+ const char* name,
+ int level,
+ const char* format,
+ va_list va)
+{
+ g_string_append_vprintf(test_log_basic_buf, format, va);
+}
+
+static
+void
+test_log_basic(
+ void)
+{
+ const GLogProc fn = gutil_log_func;
+ const GLogProc2 fn2 = gutil_log_func2;
+ const int level = gutil_log_default.level;
+ GLOG_MODULE_DEFINE2_(module, "test", gutil_log_default);
+ test_log_basic_buf = g_string_new(NULL);
+ gutil_log_func = test_log_basic_fn;
+
+ module.level = GLOG_LEVEL_INHERIT;
+ gutil_log_default.level = GLOG_LEVEL_ERR;
+ gutil_log(NULL, GLOG_LEVEL_NONE, "Debug!");
+ gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
+ gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
+ gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
+ g_assert(!test_log_basic_buf->len);
+ gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
+ g_assert(test_log_basic_buf->len);
+ g_string_set_size(test_log_basic_buf, 0);
+
+ /* With NULL parent, still gutil_log_default is going to be checked */
+ module.parent = NULL;
+ gutil_log(NULL, GLOG_LEVEL_NONE, "Debug!");
+ gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
+ gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
+ gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
+ g_assert(!test_log_basic_buf->len);
+ gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
+ g_assert(test_log_basic_buf->len);
+ g_string_set_size(test_log_basic_buf, 0);
+
+ gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
+ g_assert(test_log_basic_buf->len);
+ g_string_set_size(test_log_basic_buf, 0);
+
+ /* Without log functions these calls have no effect */
+ gutil_log_func = NULL;
+ gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
+ gutil_log_func2 = NULL;
+ gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
+
+ g_string_free(test_log_basic_buf, TRUE);
+ test_log_basic_buf = NULL;
+ gutil_log_default.level = level;
+ gutil_log_func = fn;
+ gutil_log_func2 = fn2;
+}
+
+/*==========================================================================*
+ * Enabled
+ *==========================================================================*/
+
+static
+void
+test_log_enabled(
+ void)
+{
+ const GLogProc2 fn = gutil_log_func2;
+ const int level = gutil_log_default.level;
+ GLOG_MODULE_DEFINE2_(module, "test", gutil_log_default);
+
+ gutil_log_default.level = GLOG_LEVEL_NONE;
+ g_assert(gutil_log_enabled(NULL, GLOG_LEVEL_ALWAYS));
+ g_assert(!gutil_log_enabled(NULL, GLOG_LEVEL_ERR));
+ g_assert(!gutil_log_enabled(NULL, GLOG_LEVEL_NONE));
+
+ 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));
+ 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 */
+ gutil_log_default.level = GLOG_LEVEL_INHERIT;
+ g_assert(!gutil_log_enabled(&module, GLOG_LEVEL_ERR));
+ g_assert(gutil_log_enabled(&module, GLOG_LEVEL_ALWAYS));
+
+ /* Test parenting */
+ module.level = GLOG_LEVEL_INHERIT;
+ gutil_log_default.level = GLOG_LEVEL_INFO;
+ g_assert(gutil_log_enabled(&module, GLOG_LEVEL_ALWAYS));
+ g_assert(gutil_log_enabled(&module, GLOG_LEVEL_INFO));
+ g_assert(!gutil_log_enabled(&module, GLOG_LEVEL_DEBUG));
+
+ /* No handler = no logging */
+ gutil_log_func2 = NULL;
+ gutil_log_default.level = GLOG_LEVEL_VERBOSE;
+ g_assert(!gutil_log_enabled(NULL, GLOG_LEVEL_ALWAYS));
+
+ gutil_log_default.level = level;
+ gutil_log_func2 = fn;
+}
+
+/*==========================================================================*
+ * Misc
+ *==========================================================================*/
+
+static
+void
+test_log_misc(
+ void)
+{
+ const GLogProc fn = gutil_log_func;
+ g_assert(gutil_log_set_type(GLOG_TYPE_STDOUT, "test"));
+ g_assert(gutil_log_func == gutil_log_stdout);
+ g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_STDOUT));
+ g_assert(gutil_log_set_type(GLOG_TYPE_STDERR, "test"));
+ g_assert(gutil_log_func == gutil_log_stderr);
+ g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_STDERR));
+ g_assert(!gutil_log_set_type("whatever", "test"));
+ gutil_log_func = NULL;
+ g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_CUSTOM));
+ gutil_log_func = fn;
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_PREFIX "/log/"
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_PREFIX "basic", test_log_basic);
+ g_test_add_func(TEST_PREFIX "enabled", test_log_enabled);
+ g_test_add_func(TEST_PREFIX "misc", test_log_misc);
+ test_init(&test_opt, argc, argv);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_misc/test_misc.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Jolla Ltd.
+ * Copyright (C) 2016-2018 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -39,7 +39,7 @@
static TestOpt test_opt;
/*==========================================================================*
- * Basic
+ * Disconnect
*==========================================================================*/
static
@@ -53,11 +53,11 @@
static
void
-test_basic(
+test_disconnect(
void)
{
gulong id[2];
- GObject* obj = g_object_new(GUTIL_IDLE_POOL_TYPE, NULL);
+ GObject* obj = g_object_new(TEST_OBJECT_TYPE, NULL);
/* These have no effect */
gutil_disconnect_handlers(NULL, id, G_N_ELEMENTS(id));
@@ -81,6 +81,83 @@
}
/*==========================================================================*
+ * Hex2bin
+ *==========================================================================*/
+
+static
+void
+test_hex2bin(
+ void)
+{
+ guint8 buf[4];
+ GBytes* bytes;
+ gsize size;
+ const void* data;
+ static const guint8 buf1[4] = { 0x01, 0x23, 0x45, 0x67 };
+ static const guint8 buf2[4] = { 0x89, 0xab, 0xcd, 0xef };
+ g_assert(!gutil_hex2bin(NULL, 0, NULL));
+ g_assert(!gutil_hex2bin("x", 0, NULL));
+ g_assert(!gutil_hex2bin("x", 0, buf));
+ g_assert(!gutil_hex2bin("x", -1, buf));
+ g_assert(!gutil_hex2bin("x", 1, buf));
+ g_assert(!gutil_hex2bin("xy", 2, buf));
+ g_assert(!gutil_hex2bin(" 1", 2, buf));
+ g_assert(!gutil_hex2bin("1 ", 2, buf));
+ g_assert(!gutil_hex2bin("1234FG", 6, buf));
+ g_assert(gutil_hex2bin("01234567", 8, buf));
+ g_assert(!memcmp(buf, buf1, sizeof(buf)));
+ g_assert(gutil_hex2bin("89abcdef", 8, buf));
+ g_assert(!memcmp(buf, buf2, sizeof(buf)));
+ g_assert(gutil_hex2bin("89ABCDEF", 8, buf));
+ g_assert(!memcmp(buf, buf2, sizeof(buf)));
+
+ g_assert(!gutil_hex2bytes(NULL, 0));
+ g_assert(!gutil_hex2bytes("x", 0));
+ g_assert(!gutil_hex2bytes("x", 1));
+ g_assert(!gutil_hex2bytes("x", -1));
+ g_assert(!gutil_hex2bytes("xy", -1));
+ bytes = gutil_hex2bytes("01234567", -1);
+ g_assert(bytes);
+ data = g_bytes_get_data(bytes, &size);
+ g_assert(data);
+ g_assert(size == 4);
+ g_assert(!memcmp(data, buf1, sizeof(buf1)));
+ g_bytes_unref(bytes);
+}
+
+/*==========================================================================*
+ * Hexdump
+ *==========================================================================*/
+
+static
+void
+test_hexdump(
+ void)
+{
+ char buf[GUTIL_HEXDUMP_BUFSIZE];
+ static const guchar data[] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00
+ };
+
+ g_assert(gutil_hexdump(buf, data, sizeof(data)) == GUTIL_HEXDUMP_MAXBYTES);
+ g_assert(strlen(buf) == GUTIL_HEXDUMP_BUFSIZE - 1);
+ GDEBUG("%s", buf);
+ g_assert(!strcmp(buf,
+ "30 31 32 33 34 35 36 37 "
+ "38 39 3a 3b 3c 3d 3e 3f "
+ "01234567 89:;<=>?"));
+
+ g_assert(gutil_hexdump(buf, data + GUTIL_HEXDUMP_MAXBYTES, 1) == 1);
+ g_assert(strlen(buf) == 53);
+ GDEBUG("%s", buf);
+ g_assert(!strcmp(buf,
+ "00 "
+ " "
+ "."));
+}
+
+/*==========================================================================*
* Common
*==========================================================================*/
@@ -92,7 +169,14 @@
g_type_init();
G_GNUC_END_IGNORE_DEPRECATIONS;
g_test_init(&argc, &argv, NULL);
- g_test_add_func(TEST_PREFIX "basic", test_basic);
+
+ gutil_log_timestamp = FALSE;
+ gutil_log_default.level = g_test_verbose() ?
+ GLOG_LEVEL_VERBOSE : GLOG_LEVEL_NONE;
+
+ 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);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_misc/test_misc.dsp
^
|
@@ -93,6 +93,10 @@
SOURCE=.\test_misc.c
# End Source File
+# Begin Source File
+
+SOURCE=..\common\test_object.c
+# End Source File
# End Group
# Begin Group "Header Files"
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_ring/Makefile
^
|
@@ -2,6 +2,4 @@
EXE = test_ring
-PKGS = gobject-2.0
-
include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_ring/test_ring.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Jolla Ltd.
+ * 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:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -33,7 +33,6 @@
#include "test_common.h"
#include "gutil_ring.h"
-#include "gutil_log.h"
static TestOpt test_opt;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/logger/src/libglibutil/test/test_strv/test_strv.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2016 Jolla Ltd.
+ * Copyright (C) 2015-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -13,8 +13,8 @@
* 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
+ * 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"
@@ -55,6 +55,7 @@
g_assert(!gutil_strv_at(sv, 2));
g_assert(!gutil_strv_at(sv, 3));
g_assert(!gutil_strv_at(NULL, 0));
+ g_assert(!gutil_strv_strip(NULL));
g_strfreev(sv);
}
@@ -163,6 +164,23 @@
}
/*==========================================================================*
+ * Strip
+ *==========================================================================*/
+
+static
+void
+test_strip(
+ void)
+{
+ char** in = g_strsplit(" a,b , c ,", ",", 0);
+ char** expect = g_strsplit("a,b,c,", ",", 0);
+ g_assert(gutil_strv_strip(in) == in);
+ g_assert(gutil_strv_equal(in, expect));
+ g_strfreev(in);
+ g_strfreev(expect);
+}
+
+/*==========================================================================*
* Common
*==========================================================================*/
@@ -176,6 +194,7 @@
g_test_add_func(TEST_PREFIX "find", test_find);
g_test_add_func(TEST_PREFIX "remove", test_remove);
g_test_add_func(TEST_PREFIX "sort", test_sort);
+ g_test_add_func(TEST_PREFIX "strip", test_strip);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/ofono/ofono.pro
^
|
@@ -131,7 +131,12 @@
$${LOGGER_LIB_DIR}/qml \
$${LOGGER_LIB_DIR}/settings
-TRANSLATION_FILES = $${NAME} $${NAME}-pl $${NAME}-ru $${NAME}-sv
+TRANSLATION_FILES = \
+ $${NAME} \
+ $${NAME}-nl \
+ $${NAME}-pl \
+ $${NAME}-ru \
+ $${NAME}-sv
for(t, TRANSLATION_FILES) {
suffix = $$replace(t,-,_)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/ofono/src/main.cpp
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016-2017 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2017 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -199,6 +199,7 @@
for (int i=0; i<modems.count(); i++) {
QString path(modems.at(i));
HDEBUG(path);
+ dumpOfonoInfo(path, "Modem.GetProperties");
dumpOfonoInfo(path, "SimManager.GetProperties");
dumpOfonoInfo(path, "NetworkRegistration.GetProperties");
dumpOfonoInfo(path, "ConnectionManager.GetProperties");
|
[-]
[+]
|
Added |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/ofono/translations/harbour-logger-ofono-nl.ts
^
|
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="nl">
+<context>
+ <name></name>
+ <message id="logger-cover-title">
+ <source>Log</source>
+ <translation>ofono</translation>
+ </message>
+ <message id="logger-mainpage-swipe-left-hint">
+ <source>Swipe left to configure log categories</source>
+ <translation>Swipe left to configure log categories</translation>
+ </message>
+ <message id="ofono-logger-pm-fix-mobile-data">
+ <source>Fix mobile data</source>
+ <extracomment>Pull-down menu item</extracomment>
+ <translation>Mobiele gegevens herstellen</translation>
+ </message>
+ <message id="ofono-logger-pm-enable-mobile-data">
+ <source>Enable mobile data</source>
+ <extracomment>Pull-down menu item</extracomment>
+ <translation>Mobiele gegevens inschakelen</translation>
+ </message>
+ <message id="logger-logpage-pm-clear-log">
+ <source>Clear log</source>
+ <translation>Log wissen</translation>
+ </message>
+ <message id="logger-logpage-pm-pack-and-send">
+ <source>Pack and send</source>
+ <translation>Inpakken en verzenden</translation>
+ </message>
+ <message id="logger-logpage-title">
+ <source>Log</source>
+ <translation>Ofono-log</translation>
+ </message>
+ <message id="logger-logpage-msg-connected">
+ <source>Connected.</source>
+ <translation>Verbonden met ofono.</translation>
+ </message>
+ <message id="logger-logpage-msg-connect-error">
+ <source>We are having trouble connecting to the service.</source>
+ <translation>We ondervinden problemen bij het verbinden met ofono. Mogelijk biedt deze versie van ofono geen ondersteuning voor loggen.</translation>
+ </message>
+ <message id="logger-logpage-msg-disconnected">
+ <source>Connection lost.</source>
+ <translation>Verbinding met ofono verbroken.</translation>
+ </message>
+ <message id="logger-logpage-msg-log-cleared">
+ <source>Log cleared</source>
+ <translation>Log gewist</translation>
+ </message>
+ <message id="logger-categories-title">
+ <source>Log categories</source>
+ <translation>Logcategorieën</translation>
+ </message>
+ <message id="logger-categories-pm-enable-all">
+ <source>Enable all</source>
+ <translation>Alles inschakelen</translation>
+ </message>
+ <message id="logger-categories-pm-disable-all">
+ <source>Disable all</source>
+ <translation>Alles uitschakelen</translation>
+ </message>
+ <message id="logger-categories-pm-default">
+ <source>Reset to default</source>
+ <translation>Standaardwaarden herstellen</translation>
+ </message>
+ <message id="logger-categories-select-placeholder">
+ <source>Select categories</source>
+ <extracomment>Placeholder text for the search field</extracomment>
+ <translation>Selecteer categorieën</translation>
+ </message>
+ <message id="logger-categories-not-connected">
+ <source>Not connected</source>
+ <translation>Niet verbonden met ofono</translation>
+ </message>
+ <message id="logger-sharemethodlist-add-account">
+ <source>Add account</source>
+ <translation>Account toevoegen</translation>
+ </message>
+ <message id="logger-sharepage-save-ok">
+ <source>Saved %1</source>
+ <translation>%1 opgeslagen</translation>
+ </message>
+ <message id="logger-sharepage-save-error">
+ <source>Failed to save %1</source>
+ <translation>Opslaan van %1 mislukt</translation>
+ </message>
+ <message id="logger-sharepage-pm-save-to-documents">
+ <source>Save to documents</source>
+ <translation>Opslaan naar documenten</translation>
+ </message>
+ <message id="logger-sharepage-header">
+ <source>Pack and send</source>
+ <translation>Inpakken en verzenden</translation>
+ </message>
+ <message id="logger-sharepage-default-subject">
+ <source>Log</source>
+ <extracomment>Default email subject</extracomment>
+ <translation>ofono log</translation>
+ </message>
+ <message id="logger-sharepage-default-email">
+ <source></source>
+ <extracomment>Default email recipient</extracomment>
+ <translation>ofono-debug@jolla.com</translation>
+ </message>
+ <message id="logger-sharepage-warning">
+ <source>Keep in mind that some of the information contained in this archive may be considered private. If you would like to check what you are about to send, please consider sending it to yourself and checking its contents first.</source>
+ <translation>Let op: sommige informatie in dit archief is mogelijk privé. Als je wil nakijken wat je gaat verzenden, kan je het eerst naar je eigen e-mailadres verzenden en daar de inhoud controleren.</translation>
+ </message>
+ <message id="logger-sharepage-please-wait">
+ <source>Please wait</source>
+ <translation>Even geduld</translation>
+ </message>
+ <message id="logger-settings-page-header">
+ <source>Logger</source>
+ <extracomment>Page header</extracomment>
+ <translation>Ofono-logger</translation>
+ </message>
+ <message id="logger-settings-section-header-display">
+ <source>Display</source>
+ <extracomment>Section header</extracomment>
+ <translation>Weergave</translation>
+ </message>
+ <message id="logger-settings-logsizelimit">
+ <source>Screen buffer size</source>
+ <translation>Schermbuffergrootte</translation>
+ </message>
+ <message id="logger-settings-logsizelimit-description">
+ <source>Don't worry, everything will be written to the log file regardless of the screen buffer size.</source>
+ <translation>Geen zorgen, alles wordt naar het logbestand geschreven, onafhankelijk van de schermbuffergrootte.</translation>
+ </message>
+ <message id="logger-settings-logsizelimit-unlimited">
+ <source>Unlimited</source>
+ <translation>Onbeperkt</translation>
+ </message>
+ <message id="logger-settings-fontsize-label">
+ <source>Font size</source>
+ <translation>Lettergrootte</translation>
+ </message>
+ <message id="logger-settings-section-header-logging">
+ <source>Logging</source>
+ <extracomment>Section header</extracomment>
+ <translation>Bezig met loggen</translation>
+ </message>
+ <message id="logger-settings-autoenable_logging-switch-label">
+ <source>Automatically enable logging</source>
+ <extracomment>Text switch label</extracomment>
+ <translation>Loggen automatisch inschakelen</translation>
+ </message>
+ <message id="logger-settings-autoenable_logging-switch-description">
+ <source>Enable all logging categories when the application starts.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation>Schakel alle logcategorieën automatisch in bij opstarten van de toepassing.</translation>
+ </message>
+ <message id="logger-settings-autoreset_logging-switch-label">
+ <source>Automatically reset logging on exit</source>
+ <extracomment>Text switch label</extracomment>
+ <translation>Loggen automatisch herstellen naar standaardwaarden bij afsluiten</translation>
+ </message>
+ <message id="logger-settings-autoreset_logging-switch-description">
+ <source>Reset all logging categories to their default values when the application is exiting. Otherwise logging would continue in the background, wasting the system resources and eating up your battery.</source>
+ <extracomment>Text switch description</extracomment>
+ <translation>Herstel alle logcategorieën naar hun standaardwaarden wanneer de toepassing afgesloten wordt. Zoniet zou het loggen in de achtergrond blijven doorgaan, waardoor je systeembronnen nodeloos gebruikt zouden worden en je batterij sneller plat zou zijn.</translation>
+ </message>
+</context>
+</TS>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-logger-connman-1.0.12+connman.20180620093745.7.g699a084.tar.bz2/ofono/translations/harbour-logger-ofono-pl.ts
^
|
@@ -68,7 +68,7 @@
<message id="logger-categories-select-placeholder">
<source>Select categories</source>
<extracomment>Placeholder text for the search field</extracomment>
- <translation type="unfinished">Wybierz kategorie</translation>
+ <translation>Wybierz kategorie</translation>
</message>
<message id="logger-categories-not-connected">
<source>Not connected</source>
@@ -88,7 +88,7 @@
</message>
<message id="logger-sharepage-pm-save-to-documents">
<source>Save to documents</source>
- <translation>Zapisane do dokumentów</translation>
+ <translation>Zapisz do dokumentów</translation>
</message>
<message id="logger-sharepage-header">
<source>Pack and send</source>
|