Skip to content

Commit

Permalink
Merge branch 'tklock' into 'master'
Browse files Browse the repository at this point in the history
Add tklock tracking object

And a bit of a housekeeping

See merge request !2
  • Loading branch information
Slava Monich committed Nov 14, 2016
2 parents 3749522 + 708de56 commit 1d9b7b2
Show file tree
Hide file tree
Showing 10 changed files with 535 additions and 16 deletions.
8 changes: 5 additions & 3 deletions Makefile
Expand Up @@ -20,7 +20,7 @@ all: debug release pkgconfig

VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_RELEASE = 1
VERSION_RELEASE = 2

# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
Expand All @@ -39,9 +39,11 @@ LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_RELEASE)

SRC = \
mce_display.c \
mce_proxy.c
mce_proxy.c \
mce_tklock.c
GEN_SRC = \
com.nokia.mce.c
com.nokia.mce.request.c \
com.nokia.mce.signal.c

#
# Directories
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
@@ -1,3 +1,10 @@
libmce-glib (1.0.2) unstable; urgency=low

* Added mce_display_remove_handlers
* Added mce_tklock object

-- Slava Monich <slava.monich@jolla.com> Sat, 12 Nov 2016 13:26:09 +0300

libmce-glib (1.0.1) unstable; urgency=low

* Pull mce headers from mce-dev
Expand Down
6 changes: 6 additions & 0 deletions include/mce_display.h
Expand Up @@ -90,6 +90,12 @@ mce_display_remove_handler(
MceDisplay* display,
gulong id);

void
mce_display_remove_handlers(
MceDisplay* display,
gulong *ids,
guint count);

G_END_DECLS

#endif /* MCE_DISPLAY_H */
Expand Down
120 changes: 120 additions & 0 deletions include/mce_tklock.h
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2016 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.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/

#ifndef MCE_TKLOCK_H
#define MCE_TKLOCK_H

#include "mce_types.h"

G_BEGIN_DECLS

typedef enum mce_tklock_mode {
MCE_TKLOCK_MODE_LOCKED,
MCE_TKLOCK_MODE_SILENT_LOCKED,
MCE_TKLOCK_MODE_LOCKED_DIM,
MCE_TKLOCK_MODE_LOCKED_DELAY,
MCE_TKLOCK_MODE_SILENT_LOCKED_DIM,
MCE_TKLOCK_MODE_UNLOCKED,
MCE_TKLOCK_MODE_SILENT_UNLOCKED
} MCE_TKLOCK_MODE;

typedef struct mce_tklock_priv MceTklockPriv;

typedef struct mce_tklock {
GObject object;
MceTklockPriv* priv;
gboolean valid;
MCE_TKLOCK_MODE mode;
gboolean locked;
} MceTklock;

typedef void
(*MceTklockFunc)(
MceTklock* tklock,
void* arg);

MceTklock*
mce_tklock_new(
void);

MceTklock*
mce_tklock_ref(
MceTklock* tklock);

void
mce_tklock_unref(
MceTklock* tklock);

gulong
mce_tklock_add_valid_changed_handler(
MceTklock* tklock,
MceTklockFunc fn,
void* arg);

gulong
mce_tklock_add_mode_changed_handler(
MceTklock* tklock,
MceTklockFunc fn,
void* arg);

gulong
mce_tklock_add_locked_changed_handler(
MceTklock* tklock,
MceTklockFunc fn,
void* arg);

void
mce_tklock_remove_handler(
MceTklock* tklock,
gulong id);

void
mce_tklock_remove_handlers(
MceTklock* tklock,
gulong *ids,
guint count);

G_END_DECLS

#endif /* MCE_TKLOCK_H */

/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
3 changes: 2 additions & 1 deletion rpm/libmce-glib.spec
@@ -1,5 +1,5 @@
Name: libmce-glib
Version: 1.0.1
Version: 1.0.2
Release: 0
Summary: MCE client library
Group: Development/Libraries
Expand All @@ -9,6 +9,7 @@ Source: %{name}-%{version}.tar.bz2
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libglibutil)
BuildRequires: pkgconfig(mce)
Requires: libglibutil >= 1.0.5
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig

Expand Down
14 changes: 14 additions & 0 deletions spec/com.nokia.mce.request.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node name="/com/nokia/mce/request">
<interface name="com.nokia.mce.request">
<method name="get_display_status">
<arg direction="out" name="display_state" type="s"/>
</method>
<method name="get_tklock_mode">
<arg direction="out" name="mode_name" type="s"/>
</method>
</interface>
</node>
10 changes: 3 additions & 7 deletions spec/com.nokia.mce.xml → spec/com.nokia.mce.signal.xml
Expand Up @@ -3,16 +3,12 @@
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node name="/com/nokia/mce/signal">
<!-- com.nokia.mce.request -->
<interface name="com.nokia.mce.request">
<method name="get_display_status">
<arg direction="out" name="display_state" type="s"/>
</method>
</interface>
<!-- com.nokia.mce.signal -->
<interface name="com.nokia.mce.signal">
<signal name="display_status_ind">
<arg name="display_state" type="s"/>
</signal>
<signal name="tklock_mode_ind">
<arg name="tklock_mode" type="s"/>
</signal>
</interface>
</node>
28 changes: 24 additions & 4 deletions src/mce_display.c
Expand Up @@ -38,10 +38,14 @@
#include "mce_proxy.h"
#include "mce_log_p.h"

#include "mce/mode-names.h"
#include <mce/dbus-names.h>
#include <mce/mode-names.h>

#include <gutil_misc.h>

/* Generated headers */
#include "com.nokia.mce.h"
#include "com.nokia.mce.request.h"
#include "com.nokia.mce.signal.h"

struct mce_display_priv {
MceProxy* proxy;
Expand Down Expand Up @@ -115,6 +119,12 @@ mce_display_status_query_done(
mce_display_status_update(self, status);
g_free(status);
} else {
/*
* We could retry but it's probably not worth the trouble
* because the next time display state changes we receive
* display_status_ind signal and sync our state with mce.
* Until then, this object stays invalid.
*/
GWARN("Failed to query display state %s", GERRMSG(error));
g_error_free(error);
}
Expand Down Expand Up @@ -152,7 +162,6 @@ mce_display_valid_changed(
}
}


static
void
mce_display_status_ind(
Expand Down Expand Up @@ -234,6 +243,15 @@ mce_display_remove_handler(
}
}

void
mce_display_remove_handlers(
MceDisplay* self,
gulong *ids,
guint count)
{
gutil_disconnect_handlers(self, ids, count);
}

/*==========================================================================*
* Internals
*==========================================================================*/
Expand All @@ -251,7 +269,7 @@ mce_display_init(
priv->proxy_valid_id = mce_proxy_add_valid_changed_handler(priv->proxy,
mce_display_valid_changed, self);
priv->display_status_ind_id = g_signal_connect(priv->proxy->signal,
"display_status_ind", G_CALLBACK(mce_display_status_ind), self);
MCE_DISPLAY_SIG, G_CALLBACK(mce_display_status_ind), self);
}

static
Expand All @@ -262,6 +280,8 @@ mce_display_finalize(
MceDisplay* self = MCE_DISPLAY(object);
MceDisplayPriv* priv = self->priv;

g_signal_handler_disconnect(priv->proxy->signal,
priv->display_status_ind_id);
mce_proxy_unref(priv->proxy);
G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
}
Expand Down
3 changes: 2 additions & 1 deletion src/mce_proxy.c
Expand Up @@ -40,7 +40,8 @@
#include "mce/dbus-names.h"

/* Generated headers */
#include "com.nokia.mce.h"
#include "com.nokia.mce.request.h"
#include "com.nokia.mce.signal.h"

GLOG_MODULE_DEFINE("mce");

Expand Down

0 comments on commit 1d9b7b2

Please sign in to comment.