diff --git a/ChangeLog b/ChangeLog index 1ceb48c..f5d9238 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 295 $ - $Date: 2007-09-09 06:37:50 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $ + $Revision: 343 $ - $Date: 2007-12-18 06:26:28 +0100 (Tue, 18 Dec 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -84,7 +84,7 @@ allow clients use of all 'L' keys. 1.2.5svn -> current - Add compiletime check for uinput version, should resolve compilation problems on some distro's - Security improved - the daemon now sets its effective uid to nobody as soon as possible. -1.9.0SVN +1.9.0 - Add plugin API - partially rewritten event core - updated g15daemon_xmms_spectrum plugin with new features, available in trunk/g15daemon_audio_plugins (SVN) @@ -93,5 +93,26 @@ allow clients use of all 'L' keys. - g15daemon is now dependant on libg15render. - Clock now includes analog clock thanks to Rasta Freak - Moved g15daemon_xmms_spectrum plugin to separate package -- Plugins are now installed in ${PREFIX}/lib/g15daemon/${VERSION}/plugins +1.9.1 +- Plugins are now installed in ${PREFIX}/{${LIBDIR}/g15daemon/${VERSION}/plugins - OS-X support thanks to Fabrizio Sestito. +- Bugfix: libg15daemon_client: keypresses were being corrupted. +- Bugfix: libg15daemon_client: use g15_recv rather than recv. +- Bugfix: use default scheduling for all threads. +- Optimisation: minor optimisation of lcd_cycle() code. +- Security: repair some potential security holes. +- Bugfix: Backlight status was being mis-applied when cycling screens. +- Bugfix: Language bindings were not being distributed. +1.9.1->SVN +- Add exitfunc to net plugin for exit notification. +- Use pause() instead of sleeping +- create leaving var as volatile. +- Add NAME section to g15daemon_client manpages +- Tweak delay between successive keyboard reads. This reduces cpu load by + 50% on my system. +- Bugfix: Ensure that all plugin exit functions are called on leaving. +- Bugfix: if keypress event is received (very early in the startup process, + the daemon would crash. Check that expected pointers are valid. +- Bugfix: Dont attempt compilation of uinput plugin if headers are + unavailable. +- Bugfix: Write a blank buffer to the LCD before exiting. diff --git a/Makefile.am b/Makefile.am index 1517353..37b1499 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ dist-hook: rm -rf `find $(distdir)/debian -name .svn` rm -rf `find $(distdir)/contrib -name .svn` rm -rf `find $(distdir)/Documentation -name .svn` - rm -rf `find $(distdir)/lang_bindings -name .svn` + rm -rf `find $(distdir)/lang-bindings -name .svn` rm -rf `find $(distdir)/patches -name .svn` rm -rf `find $(distdir)/rpm -name .svn` rm -rf `find $(distdir)/plugins -name .svn` diff --git a/configure.in b/configure.in index 5d7dc76..1400209 100644 --- a/configure.in +++ b/configure.in @@ -1,10 +1,10 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -# $Revision: 295 $ - $Date: 2007-09-09 06:37:50 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $ +# $Revision: 334 $ - $Date: 2007-12-07 15:08:03 +0100 (Fri, 07 Dec 2007) $ $Author: mlampard $ AC_PREREQ(2.59) -AC_INIT(g15daemon, [1.9pre], [mlampard@users.sf.net]) +AC_INIT(g15daemon, [1.9.1], [mlampard@users.sf.net]) AC_PREFIX_DEFAULT(/usr) AC_CONFIG_AUX_DIR(config) AC_CANONICAL_TARGET() @@ -32,6 +32,7 @@ AC_CHECK_HEADERS([ linux/uinput.h arpa/inet.h fcntl.h stdlib.h string.h sys/sock #include #endif ]) + #if HAVE_LINUX_UINPUT_H dnl check for uinput.h version 2.4 or 2.6 ? AC_CHECK_MEMBER([struct uinput_user_dev.id], @@ -42,9 +43,12 @@ AC_CHECK_HEADERS([ linux/uinput.h arpa/inet.h fcntl.h stdlib.h string.h sys/sock #include ] ) + uinput=true dnl end of uinput version checks #endif +AM_CONDITIONAL(UINPUT_INTERFACE_PLUGIN, [test x$uinput = xtrue]) + case $host_os in *linux*) AC_DEFINE([OSTYPE_LINUX], [1],[Target OS is Linux]) diff --git a/debian/changelog b/debian/changelog index f2ad897..040484c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +g15daemon (1.9.1.0.svn346-1) unstable; urgency=low + + * New upstream version (from svn) + + -- Giacomo Catenazzi Tue, 18 Dec 2007 09:15:42 +0100 + g15daemon (1.9.0-wip.20070910-5) unstable; urgency=low * change priority to "extra" diff --git a/debian/control b/debian/control index a0a1c0f..b97326a 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: extra Maintainer: Giacomo Catenazzi Build-Depends: cdbs, debhelper (>= 5), autotools-dev, automake1.9, libtool, libg15-dev, libg15render-dev (>=1.2.0.svn250-2), libusb-dev, libfreetype6-dev -Standards-Version: 3.7.2 +Standards-Version: 3.7.3 Package: g15daemon Section: utils diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index ca882bb..0000000 --- a/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin -usr/sbin diff --git a/debian/g15daemon.install b/debian/g15daemon.install index d615007..66d885f 100644 --- a/debian/g15daemon.install +++ b/debian/g15daemon.install @@ -1,6 +1,6 @@ debian/tmp/usr/sbin/g15daemon usr/sbin -debian/tmp/usr/lib/g15daemon/1.9pre/plugins/g15plugin_uinput.so usr/lib/g15daemon/1.9pre/plugins/ -debian/tmp/usr/lib/g15daemon/1.9pre/plugins/g15plugin_tcpserver.so usr/lib/g15daemon/1.9pre/plugins/ -debian/tmp/usr/lib/g15daemon/1.9pre/plugins/g15plugin_clock.so usr/lib/g15daemon/1.9pre/plugins/ -debian/tmp/usr/share/g15daemon/splash/g15logo2.wbmp usr/share/g15daemon/splash/ +debian/tmp/usr/lib/g15daemon/1.9.1/plugins/g15plugin_uinput.so usr/lib/g15daemon/1.9.1/plugins/ +debian/tmp/usr/lib/g15daemon/1.9.1/plugins/g15plugin_tcpserver.so usr/lib/g15daemon/1.9.1/plugins/ +debian/tmp/usr/lib/g15daemon/1.9.1/plugins/g15plugin_clock.so usr/lib/g15daemon/1.9.1/plugins/ +debian/tmp/usr/share/g15daemon/splash/g15logo2.wbmp usr/share/g15daemon/splash/ diff --git a/debian/libg15daemon-client.install b/debian/libg15daemon-client.install deleted file mode 100644 index d0dbfd1..0000000 --- a/debian/libg15daemon-client.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/lib*.so.* diff --git a/g15daemon/g15_plugins.c b/g15daemon/g15_plugins.c index 05d34f5..53022d4 100644 --- a/g15daemon/g15_plugins.c +++ b/g15daemon/g15_plugins.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 179 $ - $Date: 2006-11-19 09:33:12 +0100 (Sun, 19 Nov 2006) $ $Author: mlampard $ + $Revision: 333 $ - $Date: 2007-12-02 04:50:57 +0100 (Sun, 02 Dec 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -129,7 +129,7 @@ void run_advanced_client(plugin_t *plugin_args) g15daemon_msleep(info->update_msecs); } }else{ - while(1){ + while(!leaving){ g15daemon_msleep(500); } } diff --git a/g15daemon/lcdclient_test.c b/g15daemon/lcdclient_test.c index b6aced7..ab01376 100644 --- a/g15daemon/lcdclient_test.c +++ b/g15daemon/lcdclient_test.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 300 $ - $Date: 2007-09-10 09:52:01 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $ + $Revision: 324 $ - $Date: 2007-11-29 02:45:27 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) // keystate = g15_send_cmd (g15screen_fd, G15DAEMON_GET_KEYSTATE, foo); //while(1){ -//recv(g15screen_fd, &keystate, 4, 0); +recv(g15screen_fd, &keystate, 4, 0); if(keystate) printf("keystate = %i\n",keystate); //} @@ -79,19 +79,19 @@ int main(int argc, char *argv[]) // break; /* G2,G3 & G4 change LCD backlight */ -// if(keystate & G15_KEY_G2){ -// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_DARK); -// } -// if(keystate & G15_KEY_G3){ -// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_MEDIUM); + if(keystate & G15_KEY_G2){ + retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_DARK); + } + if(keystate & G15_KEY_G3){ + retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_MEDIUM); unsigned char packet[2]; packet[0] = G15DAEMON_BACKLIGHT|G15_BRIGHTNESS_MEDIUM; printf("sent %i bytes\n",send(g15screen_fd, packet, 1, MSG_OOB )); -// } -// if(keystate & G15_KEY_G4){ -// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_BRIGHT); -// } + } + if(keystate & G15_KEY_G4){ + retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_BRIGHT); + } /* retval = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, foo); @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) // } */ - sleep(2); +// sleep(2); #ifdef TEST_KEYHANDLER /* ok.. request that all G&M keys are passed to us.. */ retval = g15_send_cmd (g15screen_fd, G15DAEMON_KEY_HANDLER, foo); diff --git a/g15daemon/linked_lists.c b/g15daemon/linked_lists.c index 78f2bf6..7bf4c23 100644 --- a/g15daemon/linked_lists.c +++ b/g15daemon/linked_lists.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 177 $ - $Date: 2006-11-18 14:46:03 +0100 (Sat, 18 Nov 2006) $ $Author: mlampard $ + $Revision: 321 $ - $Date: 2007-11-29 01:00:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -119,6 +119,7 @@ void g15daemon_lcdnode_cycle(g15daemon_t *masterlist) lcdnode_t *current_screen = masterlist->current; g15daemon_send_event(current_screen->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_HIDDEN); + do { pthread_mutex_lock(&lcdlist_mutex); @@ -132,19 +133,18 @@ void g15daemon_lcdnode_cycle(g15daemon_t *masterlist) pthread_mutex_unlock(&lcdlist_mutex); } while (current_screen != masterlist->current); + pthread_mutex_lock(&lcdlist_mutex); if(masterlist->tail == masterlist->current) { masterlist->current = masterlist->head; } else { masterlist->current = masterlist->current->prev; } - pthread_mutex_unlock(&lcdlist_mutex); - g15daemon_send_event(masterlist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE); - g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1); - pthread_mutex_lock(&lcdlist_mutex); - masterlist->current->lcd->state_changed = 1; masterlist->current->last_priority = masterlist->current; pthread_mutex_unlock(&lcdlist_mutex); + g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1); + g15daemon_send_event(masterlist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE); + } void g15daemon_lcdnode_remove (lcdnode_t *oldnode) { diff --git a/g15daemon/main.c b/g15daemon/main.c index 8374288..797e57d 100644 --- a/g15daemon/main.c +++ b/g15daemon/main.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 302 $ - $Date: 2007-09-10 09:57:53 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $ + $Revision: 346 $ - $Date: 2007-12-18 06:44:36 +0100 (Tue, 18 Dec 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -64,6 +64,10 @@ int g15daemon_send_event(void *caller, unsigned int event, unsigned long value) static unsigned long lastkeys; if(!(value & cycle_key) && !(lastkeys & cycle_key)){ lcd_t *lcd = (lcd_t*)caller; + + if(!lcd->g15plugin->info) + break; + int *(*plugin_listener)(plugin_event_t *newevent) = (void*)lcd->g15plugin->info->event_handler; plugin_event_t *newevent=g15daemon_xmalloc(sizeof(plugin_event_t)); newevent->event = event; @@ -82,9 +86,12 @@ int g15daemon_send_event(void *caller, unsigned int event, unsigned long value) g15daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno)); } if(value & G15_KEY_LIGHT){ // the backlight key was pressed - maintain user-selected state + lcd_t *displaying = lcd->masterlist->tail->lcd; lcd->masterlist->kb_backlight_state++; if(lcd->masterlist->kb_backlight_state>2) lcd->masterlist->kb_backlight_state=0; + displaying->backlight_state++; + displaying->backlight_state %= 3; // limit to 0-2 inclusive } free(newevent); }else{ @@ -168,33 +175,38 @@ static void *keyboard_watch_thread(void *lcdlist){ unsigned int keypresses = 0; int retval = 0; + static int lastkeys = 0; while (!leaving) { - + pthread_mutex_lock(&g15lib_mutex); - retval = getPressedKeys(&keypresses, 40); + retval = getPressedKeys(&keypresses, 2); pthread_mutex_unlock(&g15lib_mutex); /* every 2nd packet contains the codes we want.. immediately try again */ while (retval == G15_ERROR_TRY_AGAIN){ pthread_mutex_lock(&g15lib_mutex); - retval = getPressedKeys(&keypresses, 40); + retval = getPressedKeys(&keypresses, 2); pthread_mutex_unlock(&g15lib_mutex); } - if(retval == G15_NO_ERROR){ + if(retval == G15_NO_ERROR && lastkeys != keypresses) { g15daemon_send_event(masterlist->current->lcd, G15_EVENT_KEYPRESS, keypresses); - } - if(retval == -ENODEV && LIBG15_VERSION>=1200) { + lastkeys = keypresses; + + }else if(retval == -ENODEV && LIBG15_VERSION>=1200) { pthread_mutex_lock(&g15lib_mutex); while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving){ sleep(1); } - if(!leaving) { masterlist->current->lcd->state_changed=1; masterlist->current->lcd->ident=random();} + if(!leaving) { + masterlist->current->lcd->state_changed=1; + masterlist->current->lcd->ident=random(); + } pthread_mutex_unlock(&g15lib_mutex); } - g15daemon_msleep(10); + g15daemon_msleep(40); } return NULL; @@ -257,6 +269,7 @@ void g15daemon_sighandler(int sig) { case SIGUSR1: keyboard_backlight_off_onexit = 1; case SIGINT: + case SIGTERM: case SIGQUIT: leaving = 1; break; @@ -275,7 +288,8 @@ int main (int argc, char *argv[]) struct sigaction new_action; cycle_key = G15_KEY_L1; unsigned char user[256]; - + unsigned int lcdlevel = 1; + pthread_t keyboard_thread; pthread_t lcd_thread; memset(user,0,256); @@ -309,13 +323,13 @@ int main (int argc, char *argv[]) if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) { printf("G15Daemon version %s - %s\n",VERSION,uf_return_running() >= 0 ?"Loaded & Running":"Not Running"); - printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation",argv[0]); + printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) [level] or -v (--version) or -l (--lcdlevel) [0-2] \n\n -k will kill a previous incarnation",argv[0]); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 printf(", if uppercase -K or -KILL turn off the keyboard backlight on the way out."); #endif #endif - printf("\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n"); + printf("\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n -l set default LCD backlight level\n"); exit(0); } @@ -340,6 +354,13 @@ int main (int argc, char *argv[]) } } + if (!strncmp(daemonargs, "-l",2) || !strncmp(daemonargs, "--lcdlevel",7)) { + if((argv[i+1])!=NULL) + if(isdigit(argv[i+1][0])){ + lcdlevel = atoi(argv[i+1]); + } + } + } if(uf_return_running()>=0) { g15daemon_log(LOG_ERR,"G15Daemon already running.. Exiting"); @@ -401,7 +422,8 @@ int main (int argc, char *argv[]) setLCDContrast(1); setLEDs(0); lcdlist->kb_backlight_state=1; - setLCDBrightness(lcdlist->kb_backlight_state); + lcdlist->current->lcd->backlight_state=lcdlevel; + setLCDBrightness(lcdlevel); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 @@ -422,19 +444,12 @@ int main (int argc, char *argv[]) pthread_mutex_init(&g15lib_mutex, NULL); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr,512*1024); /* set stack to 512k - dont need 8Mb !! */ - pthread_attr_setscope(&attr,PTHREAD_SCOPE_SYSTEM); - int thread_policy=SCHED_RR; - pthread_attr_setschedpolicy(&attr,thread_policy); if (pthread_create(&keyboard_thread, &attr, keyboard_watch_thread, lcdlist) != 0) { g15daemon_log(LOG_ERR,"Unable to create keyboard listener thread. Exiting"); goto exitnow; } pthread_attr_setstacksize(&attr,128*1024); - /* all other threads have a lower priority... maybe */ - pthread_attr_setscope(&attr,PTHREAD_SCOPE_PROCESS); - thread_policy=SCHED_OTHER; - pthread_attr_setschedpolicy(&attr,thread_policy); if (pthread_create(&lcd_thread, &attr, lcd_draw_thread, lcdlist) != 0) { g15daemon_log(LOG_ERR,"Unable to create display thread. Exiting"); @@ -461,11 +476,11 @@ int main (int argc, char *argv[]) new_action.sa_flags = 0; sigaction(SIGINT, &new_action, NULL); sigaction(SIGQUIT, &new_action, NULL); + sigaction(SIGTERM, &new_action, NULL); sigaction(SIGUSR1, &new_action, NULL); do { pause(); - } while( leaving == 0); g15daemon_log(LOG_INFO,"Leaving by request"); @@ -473,6 +488,10 @@ int main (int argc, char *argv[]) pthread_join(lcd_thread,NULL); pthread_join(keyboard_thread,NULL); /* switch off the lcd backlight */ + char *blank=malloc(G15_BUFFER_LEN); + memset(blank,0,G15_BUFFER_LEN); + writePixmapToLCD((unsigned char*)blank); + free(blank); setLCDBrightness(0); #ifdef LIBG15_VERSION #if LIBG15_VERSION >= 1200 diff --git a/g15daemon/utility_funcs.c b/g15daemon/utility_funcs.c index 49ae479..e9bdf96 100644 --- a/g15daemon/utility_funcs.c +++ b/g15daemon/utility_funcs.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 190 $ - $Date: 2006-11-21 17:31:03 +0100 (Tue, 21 Nov 2006) $ $Author: mlampard $ + $Revision: 339 $ - $Date: 2007-12-15 07:10:26 +0100 (Sat, 15 Dec 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -195,18 +195,24 @@ void g15daemon_sleep(int seconds) { pthread_mutex_destroy(&dummy_mutex); } +/* microsecond sleep routine. */ +int g15daemon_usleep(int useconds) { + + struct timeval timeout; + if(useconds < 10000) + useconds = 10000; + timeout.tv_sec = useconds / 1000000; + timeout.tv_usec = useconds % 1000000; + return select (0,0,0,0,&timeout); +} + /* millisecond sleep routine. */ int g15daemon_msleep(int milliseconds) { - struct timespec timeout; - if(milliseconds>999) - milliseconds=999; - timeout.tv_sec = 0; - timeout.tv_nsec = milliseconds*1000000; - - return nanosleep (&timeout, NULL); + return g15daemon_usleep(milliseconds*1000); } + unsigned int g15daemon_gettime_ms(){ struct timeval tv; gettimeofday(&tv,NULL); @@ -367,7 +373,6 @@ char * uf_remove_whitespace(char *str){ int g15daemon_cfg_write_string(config_section_t *section, char *key, char *val){ config_items_t *new = NULL; - const char empty[]=" "; if(section==NULL) return -1; @@ -519,7 +524,7 @@ int uf_conf_open(g15daemon_t *list, char *filename) { int config_fd=-1; char *sect; char *start; - char *bar; + char *bar = NULL; int i; struct stat stats; diff --git a/libg15daemon_client/g15daemon_client.h b/libg15daemon_client/g15daemon_client.h index 16e61ca..783887d 100644 --- a/libg15daemon_client/g15daemon_client.h +++ b/libg15daemon_client/g15daemon_client.h @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 301 $ - $Date: 2007-09-10 09:55:15 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $ + $Revision: 322 $ - $Date: 2007-11-29 01:04:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -67,7 +67,7 @@ int g15_send(int sock, char *buf, unsigned int len); int g15_recv(int sock, char *buf, unsigned int len); /* send a command (defined above) to the daemon. any replies from the daemon are returned */ -int g15_send_cmd (int sock, unsigned char command, unsigned char value); +unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value); /* receive an oob byte from the daemon, used internally by g15_send_cmd, but useful elsewhere */ #define G15_FOREGROUND_SENT_OOB 1 int g15_recv_oob_answer(int sock); diff --git a/libg15daemon_client/g15daemon_net.c b/libg15daemon_client/g15daemon_net.c index c5f2793..d98c0ef 100644 --- a/libg15daemon_client/g15daemon_net.c +++ b/libg15daemon_client/g15daemon_net.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 301 $ - $Date: 2007-09-10 09:55:15 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $ + $Revision: 322 $ - $Date: 2007-11-29 01:04:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -177,7 +177,7 @@ int g15_recv_oob_answer(int sock) { return packet[0]; } -int g15_send_cmd (int sock, unsigned char command, unsigned char value) +unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value) { int retval; unsigned char packet[2]; @@ -219,9 +219,9 @@ int g15_send_cmd (int sock, unsigned char command, unsigned char value) break; case G15DAEMON_GET_KEYSTATE:{ retval = 0; - packet[0] = (unsigned char)command; - send( sock, packet, 1, MSG_OOB ); - g15_recv(sock, (char*)&retval, sizeof(retval)); + unsigned long keystate = 0; + g15_recv(sock, (char*)&keystate, sizeof(keystate)); + return keystate; break; } case G15DAEMON_IS_FOREGROUND:{ diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 255ecdd..213a750 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -3,11 +3,14 @@ METASOURCES = AUTO libdir = @G15DAEMON_PLUGIN_DIR@ AM_CFLAGS = -Wall -lib_LTLIBRARIES =g15plugin_uinput.la g15plugin_tcpserver.la g15plugin_clock.la -INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon - +if UINPUT_INTERFACE_PLUGIN g15plugin_uinput_la_SOURCES = g15_plugin_uinput.c g15plugin_uinput_la_LDFLAGS = -avoid-version -module +input_la = g15plugin_uinput.la +endif + +lib_LTLIBRARIES = ${input_la} g15plugin_tcpserver.la g15plugin_clock.la +INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon g15plugin_tcpserver_la_SOURCES = g15_plugin_net.c g15plugin_tcpserver_la_LDFLAGS = -avoid-version -module diff --git a/plugins/g15_plugin_net.c b/plugins/g15_plugin_net.c index 2f828c1..bd69fc0 100644 --- a/plugins/g15_plugin_net.c +++ b/plugins/g15_plugin_net.c @@ -17,7 +17,7 @@ (c) 2006 Mike Lampard, Philip Lawatsch, and others - $Revision: 299 $ - $Date: 2007-09-09 19:19:52 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $ + $Revision: 329 $ - $Date: 2007-11-30 06:15:06 +0100 (Fri, 30 Nov 2007) $ $Author: mlampard $ This daemon listens on localhost port 15550 for client connections, and arbitrates LCD display. Allows for multiple simultaneous clients. @@ -40,7 +40,7 @@ #include #include -static int leaving; +static int leaving = 0; int server_events(plugin_event_t *myevent); #ifndef SO_PRIORITY @@ -108,7 +108,8 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgb } else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT) { - send(sock,&lcdnode->lcd->backlight_state,1,MSG_OOB); + unsigned char retval = lcdnode->lcd->backlight_state; + send(sock,&retval,1,MSG_OOB); lcdnode->lcd->backlight_state = msgbuf[0]-0x80; lcdnode->lcd->state_changed = 1; } @@ -426,10 +427,14 @@ int server_events(plugin_event_t *event) { return G15_PLUGIN_OK; } +static void g15plugin_net_exit() { + leaving = 1; + +} /* if no exitfunc or eventhandler, member should be NULL */ plugin_info_t g15plugin_info[] = { /* TYPE, name, initfunc, updatefreq, exitfunc, eventhandler, initfunc */ - {G15_PLUGIN_LCD_SERVER, "LCDServer" , (void*)lcdserver_thread, 500, NULL, (void*)server_events, NULL}, + {G15_PLUGIN_LCD_SERVER, "LCDServer" , (void*)lcdserver_thread, 500, g15plugin_net_exit, (void*)server_events, NULL}, {G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL} }; diff --git a/rpm/g15daemon.spec b/rpm/g15daemon.spec index da93e49..6b12081 100644 --- a/rpm/g15daemon.spec +++ b/rpm/g15daemon.spec @@ -3,18 +3,16 @@ %define prefix /usr Summary: Daemon to control logitech G15 keyboards Name: g15daemon -Version: 1.2.5 +Version: 1.9.1 Release: 1 Copyright: GPL Group: Applications/System -Source: ftp://prdownloads.sf.net/g15daemon-1.2.5.tar.bz2 +Source: ftp://prdownloads.sf.net/g15daemon-1.9.1.tar.bz2 URL: http://g15daemon.sf.net Distribution: Linux Vendor: NONE Packager: Mike Lampard Buildroot: /var/tmp/g15daemon-%{PACKAGE_VERSION}-root -BuildRequires: daemon-devel -Requires: daemon Requires: libg15 Provides: g15daemon