r2645 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src
njp at sita.openmoko.org
njp at sita.openmoko.org
Mon Aug 6 14:46:09 CEST 2007
Author: njp
Date: 2007-08-06 14:46:07 +0200 (Mon, 06 Aug 2007)
New Revision: 2645
Added:
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.h
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/configure.ac
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/Makefile.am
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer-main.c
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
Log:
2007-08-06 Neil J. Patel <njp at o-hand.com>
* configure.ac:
* src/Makefile.am:
* src/dialer-main.c: (main):
* src/moko-contacts.c: (moko_contacts_lookup):
* src/moko-dialer.c: (moko_dialer_rejected),
(on_talking_accept_call), (on_incoming_call), (on_incoming_clip),
(register_network_cb), (moko_dialer_init):
* src/moko-notify.c: (moko_notify_start_vibrate),
(moko_notify_stop_vibrate), (moko_notify_start),
(moko_notify_stop), (moko_notify_dispose), (moko_notify_finalize),
(moko_notify_class_init), (moko_notify_init), (moko_notify_new):
* src/moko-notify.h:
Added a MokoNotify object, which will deal with user notification of
incoming calls.
Implemented a simple vibration notifcation for incoming calls.
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog 2007-08-06 12:46:07 UTC (rev 2645)
@@ -1,3 +1,21 @@
+2007-08-06 Neil J. Patel <njp at o-hand.com>
+
+ * configure.ac:
+ * src/Makefile.am:
+ * src/dialer-main.c: (main):
+ * src/moko-contacts.c: (moko_contacts_lookup):
+ * src/moko-dialer.c: (moko_dialer_rejected),
+ (on_talking_accept_call), (on_incoming_call), (on_incoming_clip),
+ (register_network_cb), (moko_dialer_init):
+ * src/moko-notify.c: (moko_notify_start_vibrate),
+ (moko_notify_stop_vibrate), (moko_notify_start),
+ (moko_notify_stop), (moko_notify_dispose), (moko_notify_finalize),
+ (moko_notify_class_init), (moko_notify_init), (moko_notify_new):
+ * src/moko-notify.h:
+ Added a MokoNotify object, which will deal with user notification of
+ incoming calls.
+ Implemented a simple vibration notifcation for incoming calls.
+
2007-08-03 Neil J. Patel <njp at o-hand.com>
* src/moko-contacts.c: (moko_contacts_lookup):
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/configure.ac
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/configure.ac 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/configure.ac 2007-08-06 12:46:07 UTC (rev 2645)
@@ -17,7 +17,8 @@
libebook-1.2
libmokojournal2
libmokogsmd2
- libmokoui2)
+ libmokoui2
+ gstreamer-0.10)
old_cflags=$CFLAGS
CFLAGS=$DIALER_CFLAGS
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/Makefile.am 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/Makefile.am 2007-08-06 12:46:07 UTC (rev 2645)
@@ -22,6 +22,8 @@
moko-history.h \
moko-keypad.c \
moko-keypad.h \
+ moko-notify.c \
+ moko-notify.h \
moko-talking.c \
moko-talking.h
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer-main.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer-main.c 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/dialer-main.c 2007-08-06 12:46:07 UTC (rev 2645)
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
+#include <gst/gst.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
@@ -106,6 +107,7 @@
/* Initialize Threading & GTK+ */
gtk_init (&argc, &argv);
+ gst_init (&argc, &argv);
moko_stock_register ();
/* Try and setup our DBus service */
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c 2007-08-06 12:46:07 UTC (rev 2645)
@@ -89,7 +89,7 @@
entry = g_hash_table_lookup (priv->prefixes, number);
- if (entry && !GDK_IS_PIXBUF (entry->contact->photo))
+ if (!GDK_IS_PIXBUF (entry->contact->photo))
moko_contacts_get_photo (contacts, entry->contact);
return entry;
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c 2007-08-06 12:46:07 UTC (rev 2645)
@@ -32,9 +32,10 @@
#include "moko-dialer.h"
#include "moko-contacts.h"
+#include "moko-history.h"
#include "moko-keypad.h"
+#include "moko-notify.h"
#include "moko-talking.h"
-#include "moko-history.h"
G_DEFINE_TYPE (MokoDialer, moko_dialer, G_TYPE_OBJECT)
@@ -60,6 +61,7 @@
MokoGsmdConnection *connection;
MokoJournal *journal;
MokoContacts *contacts;
+ MokoNotify *notify;
/* The shared MokoJournalEntry which is constantly created */
MokoJournalEntry *entry;
@@ -206,6 +208,9 @@
priv->status = DIALER_STATUS_NORMAL;
+ /* Stop the notification */
+ moko_notify_stop (priv->notify);
+
if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)) == 3)
gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), 0);
@@ -282,6 +287,9 @@
priv->status = DIALER_STATUS_TALKING;
+ /* Stop the notification */
+ moko_notify_stop (priv->notify);
+
/* Finalise and add the journal entry */
if (priv->entry)
{
@@ -420,6 +428,9 @@
gtk_window_present (GTK_WINDOW (priv->window));
+ /* Start the notification */
+ moko_notify_start (priv->notify);
+
g_signal_emit (G_OBJECT (dialer), dialer_signals[INCOMING_CALL], 0, NULL);
}
@@ -440,7 +451,6 @@
&& (strcmp (number, last) == 0)
&& ((GDK_CURRENT_TIME - timestamp) < 1500))
{
- timestamp = GDK_CURRENT_TIME;
return;
}
if (last)
@@ -557,7 +567,7 @@
*/
if (priv->registered)
{
- g_print ("Netwok Registered\n");
+ g_print ("Network Registered\n");
return FALSE;
}
else
@@ -704,6 +714,9 @@
/* Load the contacts store */
priv->contacts = moko_contacts_get_default ();
+ /* Load the notification object */
+ priv->notify = moko_notify_new ();
+
/* Create the window */
priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (priv->window), "delete-event",
Added: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c 2007-08-06 12:46:07 UTC (rev 2645)
@@ -0,0 +1,176 @@
+/*
+ * moko-notify; a Notification object. This deals with notifying the user
+ * of an incoming call.
+ *
+ * Authored by OpenedHand Ltd <info at openedhand.com>
+ *
+ * Copyright (C) 2006-2007 OpenMoko Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * 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 Lesser Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date$) [$Author$]
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "moko-notify.h"
+
+#include <gst/gst.h>
+
+G_DEFINE_TYPE (MokoNotify, moko_notify, G_TYPE_OBJECT)
+
+#define MOKO_NOTIFY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
+ MOKO_TYPE_NOTIFY, MokoNotifyPrivate))
+
+#define DEFAULT_RINGTONE "/default_ringtone.ogg"
+#define SYS_BRIGHTNESS "/sys/class/backlight/gta01-bl/brightness"
+#define SYS_VIBRATE "/sys/class/leds/gta01:vibrator"
+
+struct _MokoNotifyPrivate
+{
+ gint i;
+};
+/*
+enum
+{
+ NOTHING,
+
+ LAST_SIGNAL
+};
+
+static guint notify_signals[LAST_SIGNAL] = {0, };
+*/
+
+static void
+moko_notify_start_vibrate (void)
+{
+ gint fd;
+ gchar buf[100];
+ gint len;
+
+ /* Set the trigger state */
+ fd = g_open (SYS_VIBRATE"/trigger", O_WRONLY, 0);
+ if (fd == -1)
+ {
+ g_warning ("Unable to open vibration device");
+ return;
+ }
+ len = g_sprintf (buf, "%s", "timer");
+ write (fd, buf, len);
+ close (fd);
+
+ /* Set the 'on' delay */
+ fd = g_open (SYS_VIBRATE"/delay_on", O_WRONLY, 0);
+ if (fd == -1)
+ {
+ g_warning ("Unable to open timer 'delay_on'");
+ return;
+ }
+ len = g_sprintf (buf, "%d", 500);
+ write (fd, buf, len);
+ close (fd);
+
+ /* Set the 'off' delay, this also starts the vibration */
+ fd = g_open (SYS_VIBRATE"/delay_off", O_WRONLY, 0);
+ if (fd == -1)
+ {
+ g_warning ("Unable to open timer 'delay_off'");
+ return;
+ }
+ len = g_sprintf (buf, "%d", 1000);
+ write (fd, buf, len);
+ close (fd);
+}
+
+static void
+moko_notify_stop_vibrate (void)
+{
+ gint fd;
+ gchar buf[100];
+ gint len;
+
+ /* Set the trigger state to none*/
+ fd = g_open (SYS_VIBRATE"/trigger", O_WRONLY, 0);
+ if (fd == -1)
+ {
+ g_warning ("Unable to open vibration device");
+ return;
+ }
+ len = g_sprintf (buf, "%s", "none");
+ write (fd, buf, len);
+ close (fd);
+}
+
+/* We need to do a few things here:
+ * 1. If the backlight is dimmed down, undim it
+ * 2. Start playing the ringtone
+ * 3. Start the vibration alert
+ */
+void
+moko_notify_start (MokoNotify *notify)
+{
+ moko_notify_start_vibrate ();
+}
+
+/* Stop the ringtone and the vibration alert */
+void
+moko_notify_stop (MokoNotify *notify)
+{
+ moko_notify_stop_vibrate ();
+}
+
+/* GObject functions */
+static void
+moko_notify_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (moko_notify_parent_class)->dispose (object);
+}
+
+static void
+moko_notify_finalize (GObject *notify)
+{
+ G_OBJECT_CLASS (moko_notify_parent_class)->finalize (notify);
+}
+
+static void
+moko_notify_class_init (MokoNotifyClass *klass)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS (klass);
+
+ obj_class->finalize = moko_notify_finalize;
+ obj_class->dispose = moko_notify_dispose;
+
+ g_type_class_add_private (obj_class, sizeof (MokoNotifyPrivate));
+}
+
+static void
+moko_notify_init (MokoNotify *notify)
+{
+ MokoNotifyPrivate *priv;
+
+ priv = notify->priv = MOKO_NOTIFY_GET_PRIVATE (notify);
+}
+
+MokoNotify*
+moko_notify_new (void)
+{
+ MokoNotify *notify = NULL;
+
+ notify = g_object_new (MOKO_TYPE_NOTIFY, NULL);
+
+ return notify;
+}
Added: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.h 2007-08-06 10:59:30 UTC (rev 2644)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.h 2007-08-06 12:46:07 UTC (rev 2645)
@@ -0,0 +1,77 @@
+/*
+ * moko-notify; a Notification object. This deals with notifying the user
+ * of an incoming call.
+ *
+ * Authored by OpenedHand Ltd <info at openedhand.com>
+ *
+ * Copyright (C) 2006-2007 OpenMoko Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; version 2 of the license.
+ *
+ * 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 Lesser Public License for more details.
+ *
+ * Current Version: $Rev$ ($Date$) [$Author$]
+ */
+
+#ifndef _HAVE_MOKO_NOTIFY_H
+#define _HAVE_MOKO_NOTIFY_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MOKO_TYPE_NOTIFY (moko_notify_get_type ())
+
+#define MOKO_NOTIFY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MOKO_TYPE_NOTIFY, MokoNotify))
+
+#define MOKO_NOTIFY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MOKO_TYPE_NOTIFY, MokoNotifyClass))
+
+#define MOKO_IS_NOTIFY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MOKO_TYPE_NOTIFY))
+
+#define MOKO_IS_NOTIFY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MOKO_TYPE_NOTIFY))
+
+#define MOKO_NOTIFY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MOKO_TYPE_NOTIFY, MokoNotifyClass))
+
+typedef struct _MokoNotify MokoNotify;
+typedef struct _MokoNotifyClass MokoNotifyClass;
+typedef struct _MokoNotifyPrivate MokoNotifyPrivate;
+
+struct _MokoNotify
+{
+ GObject parent;
+
+ /*< private >*/
+ MokoNotifyPrivate *priv;
+};
+
+struct _MokoNotifyClass
+{
+ /*< private >*/
+ GObjectClass parent_class;
+};
+
+GType moko_notify_get_type (void) G_GNUC_CONST;
+
+MokoNotify*
+moko_notify_new (void);
+
+void
+moko_notify_start (MokoNotify *notify);
+
+void
+moko_notify_stop (MokoNotify *notify);
+
+G_END_DECLS
+
+#endif /* _HAVE_MOKO_NOTIFY_H */
More information about the commitlog
mailing list