The Following User Says Thank You to jaeezzy For This Useful Post: | ||
![]() |
2010-03-08
, 10:48
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#2
|
The Following 2 Users Say Thank You to krk969 For This Useful Post: | ||
![]() |
2010-03-08
, 16:48
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#3
|
not a 100% sure about this until I try it myself but you could register for the call state signal using dbus wrappers
MCE_CALL_STATE_SIG can have states like
MCE_CALL_STATE_NONE "none"
No ongoing call.
#define MCE_CALL_STATE_RINGING "ringing"
Call ringing.
#define MCE_CALL_STATE_ACTIVE "active"
Call on-going.
you can activate listening to the keyboard status when the call is active or ringing.
You could further listen to call status only when screen is on ( MCE_DISPLAY_STATUS_GET ), that would save battery as well.
btw, I like your idea, good luck !
![]() |
2010-03-08
, 16:54
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#4
|
![]() |
2010-03-08
, 17:06
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#5
|
In combination with the D-Bus method calls and signals it provides (http://maemo.org/api_refs/5.0/5.0-fi...5a46afdad43a94 and http://maemo.org/api_refs/5.0/5.0-fi...1a695659d394da in particular). What are you programming your daemon in? Are you using Qt or GLib/GTK?
![]() |
2010-03-08
, 17:10
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#6
|
![]() |
2010-03-08
, 17:13
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#7
|
![]() |
2010-03-08
, 17:23
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#8
|
The Following User Says Thank You to qwerty12 For This Useful Post: | ||
![]() |
2010-03-08
, 17:51
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#9
|
**** no!
@jaeezzy
Here's an example, using the lovely DBus-GLib bindings, that gets the current state and prints it out: http://slexy.org/view/s287btiNxS
As you can see, I'm not in the habit of commenting my code. I'll try and explain anything asked, but I'm no expert on D-Bus.
When I've finished it, I'll post again with another sample that automatically prints out the state when it changes.
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> #include <glib.h> #include <stdio.h> #include <string.h> #include <mce/dbus-names.h> #include <mce/mode-names.h> #include <stdlib.h> typedef struct{ DBusGProxy *proxy; gchar *call_state; gchar *call_e_state; } PSSwitcherD; static void mce_call_state_changed(DBusGProxy*, const gchar*, const gchar*, gpointer); static void private_free(gpointer); static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; int main(int argc, char *argv[]){ DBusGConnection *dbus; GError *dbus_err = NULL; PSSwitcherD *switcher; switcher = g_new0(PSSwitcherD, 1); g_static_private_set(&private_key, switcher, private_free); dbus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &dbus_err); if (!dbus){ g_print("D-BUS Connection FAILED!!!\n"); g_clear_error(&dbus_err); return 1; } switcher->proxy = dbus_g_proxy_new_for_name(dbus, MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF); dbus_g_proxy_add_signal(switcher->proxy, MCE_CALL_STATE_SIG, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal(switcher->proxy, MCE_CALL_STATE_SIG, G_CALLBACK(mce_call_state_changed), NULL, NULL); g_print("Requesting current call state...\n"); dbus_g_proxy_call(switcher->proxy, MCE_CALL_STATE_GET, &dbus_err, G_TYPE_INVALID, G_TYPE_STRING, &switcher->call_state, G_TYPE_STRING, &switcher->call_e_state, G_TYPE_INVALID); if (dbus_err){ g_print("couldn't request current call state.\n"); g_clear_error(&dbus_err); }else{ g_print("Current state is %s.\n", switcher->call_state); } return 0; } static void mce_call_state_changed(DBusGProxy *proxy, const gchar *call_state, const gchar *call_e_state, gpointer user_data){ PSSwitcherD *switcher; switcher = g_static_private_get(&private_key); g_return_if_fail(switcher != NULL); g_print("Call state changed to %s\n", call_state); g_free(switcher->call_state); switcher->call_state = g_strdup(call_state); g_free(switcher->call_e_state); switcher->call_e_state = g_strdup(call_e_state); if (g_strcmp0(call_state, MCE_CALL_STATE_NONE)) g_print("DOING NOTHING\n"); else if (g_strcmp0(call_state, MCE_CALL_STATE_RINGING)) g_print("BLOODY RINGING\n"); } static void private_free(gpointer data){ PSSwitcherD *switcher; switcher = data; g_free(switcher->call_state); g_free(switcher->call_e_state); if (switcher->proxy) g_object_unref(switcher->proxy); g_free(switcher); }
![]() |
2010-03-08
, 17:53
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#10
|
When I've finished it, I'll post again with another sample that automatically prints out the state when it changes.
I'm trying to create a simple daemon that switches the speaker on/off by sliding the keyboard while on the call. I'm getting the result but the thing is its switching all the time and continuously monitoring the devices which, of course, gonna shorten battery life. So I'm trying to create a daemon that gets triggered only when the user clicks the "Answer" button to answer a call and stops with the user ending the call. So, just wondering if this is possible.
In the mean time I'm going through the script from shortcutd that triggers the daemon and at the top it has "start on XSESSIONS_STARTING" followed by "stop on stopped hal" -: (ya I'm just learning to write one and most of the things in this script is kinda foreign language to me