--- /dev/null
+SUBDIRS = src
+HILDON_STATUS_PANEL_LIB_DIR=$(shell pkg-config libhildondesktop-1 --variable=hildondesktoplibdir)
+HILDON_STATUS_PANEL_DATA_DIR=$(shell pkg-config libhildondesktop-1 --variable=hildonstatusmenudesktopentrydir)
+BUILDDIR=build
+SP_LIB=lens-cover-reminder-sp.so
+DATA_FILE_SP=lens-cover-reminder-sp.desktop
+IMAGE_PATH=/usr/share/icons/hicolor/18x18/hildon/
+
+all: create_builddir subdirs
+
+install: all
+ install -d $(DESTDIR)/$(HILDON_STATUS_PANEL_LIB_DIR)
+ install -m 644 $(BUILDDIR)/$(SP_LIB) $(DESTDIR)/$(HILDON_STATUS_PANEL_LIB_DIR)
+ install -d $(DESTDIR)/$(HILDON_CONTROL_PANEL_DATA_DIR)
+ install -d $(DESTDIR)/$(HILDON_STATUS_PANEL_DATA_DIR)
+ install -m 644 data/$(DATA_FILE_SP) $(DESTDIR)/$(HILDON_STATUS_PANEL_DATA_DIR)
+ install -d $(DESTDIR)/$(IMAGE_PATH)
+ install -m 644 data/statusarea_lens_cover_reminder.png $(DESTDIR)/$(IMAGE_PATH)
+
+
+subdirs: $(SUBDIRS)
+
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+create_builddir:
+ mkdir -p build
+
+.PHONY: all clean install $(SUBDIRS)
+
+clean:
+ rm -rf build
+ for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean);done
--- /dev/null
+[Desktop Entry]
+Name=Lens Cover Reminder
+Comment=Reminds you for the open lens cover
+Icon=general_email
+Categories=conditional
+Type=default
+X-Path=lens-cover-reminder-sp.so
--- /dev/null
+The Debian Package lens-cover-reminder-sp
+----------------------------
+
+Comments regarding the Package
+
+ -- Nicolai Hess <nicolaihess@web.de> Wed, 12 May 2010 00:09:23 +0200
--- /dev/null
+lens-cover-reminder-sp for Debian
+---------------------------------
+
+<possible notes regarding this package - if none, delete this file>
+
+ -- Nicolai Hess <nicolaihess@web.de> Wed, 12 May 2010 00:09:23 +0200
--- /dev/null
+lens-cover-reminder-sp (0.3) unstable; urgency=low
+
+ * changed the icon again
+ * changed bugtracker
+
+ -- Nicolai Hess <nicolaihess@web.de> Tue, 18 May 2010 00:52:23 +0200
+
+lens-cover-reminder-sp (0.2) unstable; urgency=low
+
+ * changed the app-icon (XB-Maemo-Icon)
+
+ -- Nicolai Hess <nicolaihess@web.de> Sun, 16 May 2010 22:18:02 +0200
+
+lens-cover-reminder-sp (0.1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Nicolai Hess <nicolaihess@web.de> Wed, 12 May 2010 00:09:23 +0200
--- /dev/null
+Source: lens-cover-reminder-sp
+Priority: extra
+Maintainer: Nicolai Hess <nicolaihess@web.de>
+Build-Depends: debhelper (>= 5), libgtk2.0-dev, libhildon1-dev, libhildondesktop1-dev, libdbus-1-dev, mce-dev
+Standards-Version: 3.7.2
+Section: user/desktop
+
+Package: lens-cover-reminder-sp
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Reminds you of the open lens
+ Shows a little statusbar icon while the lens
+ is open and vibrates on screen lock
+XB-Maemo-Display-Name:Lens Cover Reminder
+XSBC-Bugtracker: https://garage.maemo.org/tracker/?group_id=1611
+XB-Maemo-Icon-26:
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c
+ 6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0
+ SU1FB9oFERYoMtIVCosAAADcSURBVGje7Zi9CsIwFEZvpXPA1SlLyOriUwQh
+ u0/hk/gqBclTuLhqlkyuQgbXdguhDYJi1Kvfmb6S0PSS09sfIgAAAAAAwJZG
+ a91zLqAlIhJCsLz4GCPNuCvU5geH5foti66O+5edi/0O/JZCOZvbqdqi5yx3
+ XZfyYr6dzL1cdylba6EQH4VylFIpe++xAyjgUYVqUuosoxlQCArdwxiTspRy
+ Mh5CSNk5B4Wg0Jhcm5JCeJChABTw5Tdx3uefGYdCLBSq+RFTej1AF+JEo7Xu
+ 8W8UCv17G40xEvgQA+gnLQnOJA+wAAAAAElFTkSuQmCC
+ ====
--- /dev/null
+This is lens-cover-reminder-sp, written and maintained by Nicolai Hess <nicolaihess@web.de>
+on Wed, 12 May 2010 00:09:23 +0200.
+
+The original source can always be found at:
+ ftp://ftp.debian.org/dists/unstable/main/source/
+
+Copyright Holder: Nicolai Hess
+
+License:
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this package; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+# shared library versions, option 1
+version=2.0.5
+major=2
+# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
+#version=`ls src/.libs/lib*.so.* | \
+# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
+#major=`ls src/.libs/lib*.so.* | \
+# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+
+ touch configure-stamp
+
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/tmp
+ $(MAKE) DESTDIR=$(CURDIR)/debian/lens-cover-reminder-sp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_python
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+OBJS=lens-cover-reminder-sp.o
+SOURCES=lens-cover-reminder-sp.c
+BUILDDIR=../build
+LIB=$(BUILDDIR)/lens-cover-reminder-sp.so
+PKG_FLAGS=$(shell pkg-config hildon-1 libhildondesktop-1 --libs --cflags)
+CCFLAGS=-shared
+CC=gcc
+
+all: $(LIB)
+
+
+$(LIB): $(OBJS)
+ $(CC) $(CCFLAGS) $(PKG_FLAGS) $(OBJS) -o $(LIB)
+
+.c.o:
+ $(CC) $(CCFLAGS) $(PKG_FLAGS) -c $< -o $@
+
+
+.PHONY: clean all
+
+clean:
+ rm $(OBJS)
\ No newline at end of file
--- /dev/null
+/*
+ * lenscover reminder statusbar plugin.
+ * Copyright (C) 2010 Nicolai Hess
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <fcntl.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+#include <mce/dbus-names.h>
+#include <mce/mode-names.h>
+
+#include "lens-cover-reminder-sp.h"
+
+#define LENS_COVER_STATUS_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
+ TYPE_LENS_COVER_STATUS_PLUGIN, LensCoverStatusPluginPrivate))
+
+
+struct _LensCoverStatusPluginPrivate
+{
+ DBusGConnection *dbus_conn;
+ DBusGProxy *dbus_proxy_cover;
+ DBusGProxy *dbus_proxy_lock;
+};
+
+HD_DEFINE_PLUGIN_MODULE(LensCoverStatusPlugin, lens_cover_status_plugin, HD_TYPE_STATUS_MENU_ITEM);
+
+static gboolean
+lens_cover_status_plugin_cover_is_open()
+{
+ int fd;
+ char state[7];
+ fd = open("/sys/devices/platform/gpio-switch/cam_shutter/state", O_RDONLY);
+ if(fd)
+ {
+ read(fd, state, 7 );
+ if(!g_str_has_prefix(state, "closed"))
+ {
+ return TRUE;
+ }
+ close( fd );
+ }
+ return FALSE;
+}
+
+static void
+lens_cover_status_plugin_show_icon(LensCoverStatusPlugin* plugin)
+{
+ GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "statusarea_lens_cover_reminder", 18, 0, NULL);
+ if(pixbuf)
+ {
+ hd_status_plugin_item_set_status_area_icon(HD_STATUS_PLUGIN_ITEM(plugin), pixbuf);
+ g_object_unref(pixbuf);
+ }
+}
+
+static void
+lens_cover_status_plugin_hide_icon(LensCoverStatusPlugin* plugin)
+{
+ hd_status_plugin_item_set_status_area_icon(HD_STATUS_PLUGIN_ITEM(plugin), NULL);
+}
+
+static void
+lens_cover_status_plugin_vibrate(LensCoverStatusPlugin* plugin,
+ gboolean activate)
+{
+ static gchar* pattern = "PatternIncomingMessage";
+ const gchar* method = (activate) ? MCE_ACTIVATE_VIBRATOR_PATTERN : MCE_DEACTIVATE_VIBRATOR_PATTERN;
+ if(plugin->priv->dbus_conn)
+ {
+ DBusGProxy* proxy = dbus_g_proxy_new_for_name(plugin->priv->dbus_conn,
+ MCE_SERVICE,
+ MCE_REQUEST_PATH,
+ MCE_REQUEST_IF);
+ if(proxy)
+ {
+ dbus_g_proxy_call_no_reply(proxy,
+ method,
+ G_TYPE_STRING, pattern,
+ G_TYPE_INVALID);
+ g_object_unref(proxy);
+ }
+ }
+}
+
+static void
+handle_lock_mode_changed(DBusGProxy* object,
+ const gchar* tklock_mode,
+ LensCoverStatusPlugin* plugin)
+{
+ if(lens_cover_status_plugin_cover_is_open())
+ {
+ if(g_str_has_prefix(tklock_mode, MCE_TK_LOCKED))
+ lens_cover_status_plugin_vibrate(plugin, TRUE);
+ else
+ lens_cover_status_plugin_vibrate(plugin, FALSE);
+ }
+}
+
+static void
+handle_cover_switch_changed(DBusGProxy* object,
+ const gchar* event,
+ const gchar* source,
+ LensCoverStatusPlugin* plugin)
+{
+ if(lens_cover_status_plugin_cover_is_open())
+ {
+ lens_cover_status_plugin_show_icon(plugin);
+ }
+ else
+ {
+ lens_cover_status_plugin_hide_icon(plugin);
+ }
+}
+
+static void
+lens_cover_status_plugin_finalize(GObject* object)
+{
+ LensCoverStatusPlugin* plugin = LENS_COVER_STATUS_PLUGIN(object);
+ if(plugin->priv->dbus_proxy_cover)
+ {
+ dbus_g_proxy_disconnect_signal(plugin->priv->dbus_proxy_cover,
+ "Condition",
+ G_CALLBACK(handle_cover_switch_changed),
+ plugin);
+ }
+ if(plugin->priv->dbus_proxy_lock)
+ {
+ dbus_g_proxy_disconnect_signal(plugin->priv->dbus_proxy_lock,
+ MCE_TKLOCK_MODE_SIG,
+ G_CALLBACK(handle_lock_mode_changed),
+ plugin);
+ }
+}
+
+static void
+register_dbus_signal_on_cover_switch(LensCoverStatusPlugin* plugin)
+{
+ plugin->priv->dbus_conn = NULL;
+ plugin->priv->dbus_proxy_cover = NULL;
+ plugin->priv->dbus_proxy_lock = NULL;
+ plugin->priv->dbus_conn = hd_status_plugin_item_get_dbus_g_connection(HD_STATUS_PLUGIN_ITEM(&plugin->parent),
+ DBUS_BUS_SYSTEM,
+ NULL);
+
+ if(plugin->priv->dbus_conn)
+ {
+ plugin->priv->dbus_proxy_cover = dbus_g_proxy_new_for_name(plugin->priv->dbus_conn,
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/platform_cam_shutter",
+ "org.freedesktop.Hal.Device");
+ dbus_g_proxy_add_signal(plugin->priv->dbus_proxy_cover,
+ "Condition",
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(plugin->priv->dbus_proxy_cover,
+ "Condition",
+ G_CALLBACK(handle_cover_switch_changed), plugin, NULL);
+
+ plugin->priv->dbus_proxy_lock = dbus_g_proxy_new_for_name(plugin->priv->dbus_conn,
+ MCE_SERVICE,
+ MCE_SIGNAL_PATH,
+ MCE_SIGNAL_IF);
+ dbus_g_proxy_add_signal(plugin->priv->dbus_proxy_lock,
+ MCE_TKLOCK_MODE_SIG,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(plugin->priv->dbus_proxy_lock,
+ MCE_TKLOCK_MODE_SIG,
+ G_CALLBACK(handle_lock_mode_changed), plugin, NULL);
+
+ }
+}
+
+
+static void
+lens_cover_status_plugin_class_finalize(LensCoverStatusPluginClass *klass)
+{
+}
+
+static void
+lens_cover_status_plugin_class_init(LensCoverStatusPluginClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(LensCoverStatusPluginPrivate));
+ G_OBJECT_CLASS(klass)->finalize = (GObjectFinalizeFunc)lens_cover_status_plugin_finalize;
+}
+
+static void
+lens_cover_status_plugin_init(LensCoverStatusPlugin* plugin)
+{
+ plugin->priv = LENS_COVER_STATUS_PLUGIN_GET_PRIVATE(plugin);
+ register_dbus_signal_on_cover_switch(plugin);
+ if(lens_cover_status_plugin_cover_is_open())
+ {
+ lens_cover_status_plugin_show_icon(plugin);
+ }
+ else
+ {
+ lens_cover_status_plugin_hide_icon(plugin);
+ }
+}
+
--- /dev/null
+/*
+ * lenscover reminder statusbar plugin.
+ * Copyright (C) 2010 Nicolai Hess
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef _LENS_COVER_REMINDER_H
+#define _LENS_COVER_REMINDER_H
+
+#include <libhildondesktop/libhildondesktop.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_LENS_COVER_STATUS_PLUGIN (lens_cover_status_plugin_get_type())
+
+#define LENS_COVER_STATUS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ TYPE_LENS_COVER_STATUS_PLUGIN, LensCoverStatusPlugin))
+
+#define LENS_COVER_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
+ TYPE_LENS_COVER_STATUS_PLUGIN, StatusPluginClass))
+
+#define IS_LENS_COVER_STATUS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ TYPE_LENS_COVER_STATUS_PLUGIN))
+
+#define IS_LENS_COVER_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ TYPE_LENS_COVER_STATUS_PLUGIN))
+
+
+typedef struct _LensCoverStatusPlugin LensCoverStatusPlugin;
+typedef struct _LensCoverStatusPluginClass LensCoverStatusPluginClass;
+typedef struct _LensCoverStatusPluginPrivate LensCoverStatusPluginPrivate;
+
+struct _LensCoverStatusPlugin
+{
+ HDStatusMenuItem parent;
+ LensCoverStatusPluginPrivate* priv;
+};
+
+struct _LensCoverStatusPluginClass
+{
+ HDStatusMenuItemClass parent;
+};
+
+GType lens_cover_status_plugin_get_type(void);
+
+G_END_DECLS
+#endif