Import Upstream version 1.9.5.2
This commit is contained in:
1 parent
9602397440
commit
18176a4efe
51 files changed
+46043
-361
No files matched your search
+23
-17
@@ -15,9 +15,9 @@
|
||||
along with g15daemon; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
(c) 2006 Mike Lampard, Philip Lawatsch, and others
|
||||
(c) 2006-2008 Mike Lampard, Philip Lawatsch, and others
|
||||
|
||||
$Revision: 329 $ - $Date: 2007-11-30 06:15:06 +0100 (Fri, 30 Nov 2007) $ $Author: mlampard $
|
||||
$Revision: 451 $ - $Date: 2008-01-25 15:15:04 +1030 (Fri, 25 Jan 2008) $ $Author: mlampard $
|
||||
|
||||
This daemon listens on localhost port 15550 for client connections,
|
||||
and arbitrates LCD display. Allows for multiple simultaneous clients.
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <g15daemon.h>
|
||||
|
||||
static int leaving = 0;
|
||||
int server_events(plugin_event_t *myevent);
|
||||
static int server_events(plugin_event_t *myevent);
|
||||
|
||||
#ifndef SO_PRIORITY
|
||||
#define SO_PRIORITY 12
|
||||
@@ -69,6 +69,12 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgb
|
||||
g15daemon_send_event(lcdnode,G15_EVENT_REQ_PRIORITY,1);
|
||||
break;
|
||||
}
|
||||
case CLIENT_CMD_NEVER_SELECT: { /* client can never be user-selected */
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
lcdnode->lcd->never_select = 1;
|
||||
pthread_mutex_unlock(&lcdlist_mutex);
|
||||
break;
|
||||
}
|
||||
case CLIENT_CMD_IS_FOREGROUND: { /* client wants to know if it's currently viewable */
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
memset(msgbuf,0,2);
|
||||
@@ -83,12 +89,12 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgb
|
||||
}
|
||||
case CLIENT_CMD_IS_USER_SELECTED: { /* client wants to know if it was set to foreground by the user */
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
if(lcdnode->lcd->usr_foreground) /* user manually selected this lcd */
|
||||
msgbuf[0] = '1';
|
||||
if(lcdnode->lcd->usr_foreground==1) /* user manually selected this lcd */
|
||||
msgbuf[0] = 1;
|
||||
else
|
||||
msgbuf[0] = '0';
|
||||
msgbuf[0] = 0;
|
||||
pthread_mutex_unlock(&lcdlist_mutex);
|
||||
send(sock,msgbuf,1,0);
|
||||
send(sock,msgbuf,1,MSG_OOB);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -127,7 +133,7 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgb
|
||||
}
|
||||
|
||||
/* create and open a socket for listening */
|
||||
int init_sockserver(){
|
||||
static int init_sockserver(){
|
||||
int listening_socket;
|
||||
int yes=1;
|
||||
int tos = 0x18;
|
||||
@@ -161,7 +167,7 @@ int init_sockserver(){
|
||||
}
|
||||
|
||||
|
||||
int g15_send(int sock, char *buf, unsigned int len)
|
||||
static int g15_send(int sock, char *buf, unsigned int len)
|
||||
{
|
||||
int total = 0;
|
||||
int retval = 0;
|
||||
@@ -191,7 +197,7 @@ int g15_send(int sock, char *buf, unsigned int len)
|
||||
}
|
||||
|
||||
|
||||
int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len)
|
||||
static int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len)
|
||||
{
|
||||
int total = 0;
|
||||
int retval = 0;
|
||||
@@ -239,7 +245,7 @@ int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len)
|
||||
* once the client disconnects by closing the socket, the LCD buffer is
|
||||
* removed and will no longer be displayed.
|
||||
*/
|
||||
void *lcd_client_thread(void *display) {
|
||||
static void *lcd_client_thread(void *display) {
|
||||
|
||||
lcdnode_t *g15node = display;
|
||||
lcd_t *client_lcd = g15node->lcd;
|
||||
@@ -267,7 +273,7 @@ void *lcd_client_thread(void *display) {
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
memset(client_lcd->buf,0,1024);
|
||||
g15daemon_convert_buf(client_lcd,tmpbuf);
|
||||
client_lcd->ident = random();
|
||||
g15daemon_send_refresh(client_lcd);
|
||||
pthread_mutex_unlock(&lcdlist_mutex);
|
||||
}
|
||||
}
|
||||
@@ -279,7 +285,7 @@ void *lcd_client_thread(void *display) {
|
||||
}
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
memcpy(client_lcd->buf,tmpbuf,sizeof(client_lcd->buf));
|
||||
client_lcd->ident = random();
|
||||
g15daemon_send_refresh(client_lcd);
|
||||
pthread_mutex_unlock(&lcdlist_mutex);
|
||||
}
|
||||
}
|
||||
@@ -312,7 +318,7 @@ void *lcd_client_thread(void *display) {
|
||||
|
||||
pthread_mutex_lock(&lcdlist_mutex);
|
||||
memcpy(client_lcd->buf,tmpbuf+header,buflen+header);
|
||||
client_lcd->ident = random();
|
||||
g15daemon_send_refresh(client_lcd);
|
||||
pthread_mutex_unlock(&lcdlist_mutex);
|
||||
}
|
||||
}
|
||||
@@ -327,7 +333,7 @@ exitthread:
|
||||
}
|
||||
|
||||
/* poll the listening socket for connections, spawning new threads as needed to handle clients */
|
||||
int g15_clientconnect (g15daemon_t **g15daemon, int listening_socket) {
|
||||
static int g15_clientconnect (g15daemon_t **g15daemon, int listening_socket) {
|
||||
|
||||
int conn_s;
|
||||
struct pollfd pfd[1];
|
||||
@@ -400,7 +406,7 @@ static void lcdserver_thread(void *lcdlist){
|
||||
}
|
||||
|
||||
/* incoming events */
|
||||
int server_events(plugin_event_t *event) {
|
||||
static int server_events(plugin_event_t *event) {
|
||||
lcd_t *lcd = (lcd_t*) event->lcd;
|
||||
|
||||
switch (event->event)
|
||||
@@ -435,6 +441,6 @@ static void g15plugin_net_exit() {
|
||||
/* 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, g15plugin_net_exit, (void*)server_events, NULL},
|
||||
{G15_PLUGIN_LCD_SERVER, "LCDServer" , (void*)lcdserver_thread, 500, (void*)g15plugin_net_exit, (void*)server_events, NULL},
|
||||
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
|
||||
};
|
||||
Reference in new issue
Block a user