|
From: <mla...@us...> - 2006-11-13 05:26:43
|
Revision: 132
http://svn.sourceforge.net/g15daemon/?rev=132&view=rev
Author: mlampard
Date: 2006-11-12 21:25:42 -0800 (Sun, 12 Nov 2006)
Log Message:
-----------
define public vs internal-only funcs
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/g15_plugins.c
trunk/g15daemon-wip/g15daemon/g15daemon.h
trunk/g15daemon-wip/g15daemon/gfx_primitives.c
trunk/g15daemon-wip/g15daemon/linked_lists.c
trunk/g15daemon-wip/g15daemon/main.c
trunk/g15daemon-wip/g15daemon/utility_funcs.c
trunk/g15daemon-wip/plugins/g15_plugin_clock.c
trunk/g15daemon-wip/plugins/g15_plugin_net.c
Modified: trunk/g15daemon-wip/g15daemon/g15_plugins.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15_plugins.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/g15_plugins.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -26,6 +26,7 @@
g15_plugin.c
simple plugin loader - loads each plugin and runs each one in it's own thread. a bit expensive probably
*/
+#define G15DAEMON_BUILD 1
#include <pthread.h>
#include <stdio.h>
@@ -40,7 +41,7 @@
#include <unistd.h>
#include <dirent.h>
#include <libg15.h>
-#include "g15daemon.h"
+#include <g15daemon.h>
#include <dlfcn.h>
#include <pwd.h>
@@ -48,7 +49,7 @@
extern int leaving;
-void * g15_dlopen_plugin(char *name,unsigned int library) {
+void * g15daemon_dlopen_plugin(char *name,unsigned int library) {
void * handle;
char * error;
@@ -65,7 +66,7 @@
return handle;
}
-int g15_dlclose_plugin(void *handle) {
+int g15daemon_dlclose_plugin(void *handle) {
dlclose(handle);
}
@@ -90,7 +91,7 @@
plugin_retval = (*plugin)((void*)client_lcd);
if(info->update_msecs<50)
info->update_msecs = 50;
- pthread_msleep(info->update_msecs);
+ g15daemon_msleep(info->update_msecs);
}
if(plugin_close!=NULL){
@@ -98,7 +99,7 @@
}
if(!leaving)
- lcdnode_remove(display);
+ g15daemon_lcdnode_remove(display);
}
void run_advanced_client(plugin_t *plugin_args)
{
@@ -125,11 +126,11 @@
while(((*plugin_run)(plugin_args->args))==G15_PLUGIN_OK && !leaving){
if(info->update_msecs<50)
info->update_msecs = 50;
- pthread_msleep(info->update_msecs);
+ g15daemon_msleep(info->update_msecs);
}
}else{
while(1){
- pthread_msleep(500);
+ g15daemon_msleep(500);
}
}
if(plugin_close) {
@@ -159,7 +160,7 @@
free(plugin_args);
g15daemon_log(LOG_INFO,"Removed plugin %s",info->name);
- g15_dlclose_plugin(handle);
+ g15daemon_dlclose_plugin(handle);
}
@@ -173,14 +174,14 @@
pthread_attr_t attr;
lcdnode_t *clientnode;
- if((plugin_handle = g15_dlopen_plugin(name,G15_PLUGIN_NONSHARED))!=NULL) {
+ if((plugin_handle = g15daemon_dlopen_plugin(name,G15_PLUGIN_NONSHARED))!=NULL) {
plugin_t *plugin_args=malloc(sizeof(plugin_t));
plugin_args->info = dlsym(plugin_handle, "g15plugin_info");
dlerror();
if(!plugin_args->info) { /* if it doesnt have a valid struct, we should just load it as a library... but we dont at the moment FIXME */
g15daemon_log(LOG_ERR,"%s is not a valid g15daemon plugin\n",name);
- g15_dlclose_plugin(plugin_handle);
+ g15daemon_dlclose_plugin(plugin_handle);
dlerror();
return;
}
@@ -195,7 +196,7 @@
lcdlist_t *foolist = (lcdlist_t*)displaylist;
/* FIXME we should just sort out the linked list stuff instead of overriding it */
if((int)foolist->numclients>=1){
- clientnode = lcdnode_add((void*)g15daemon_lcds);
+ clientnode = g15daemon_lcdnode_add((void*)g15daemon_lcds);
}else {
clientnode = foolist->tail;
foolist->numclients++;
@@ -239,7 +240,7 @@
strncat(pluginname,ep->d_name,200);
g15daemon_log(LOG_INFO, "Loading plugin %s",pluginname);
g15_plugin_load (displaylist, pluginname);
- pthread_msleep(20);
+ g15daemon_msleep(20);
}
}
(void) closedir (directory);
Modified: trunk/g15daemon-wip/g15daemon/g15daemon.h
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15daemon.h 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/g15daemon.h 2006-11-13 05:25:42 UTC (rev 132)
@@ -193,53 +193,53 @@
/* server hello */
#define SERV_HELO "G15 daemon HELLO"
-/* uinput & keyboard control */
-#ifdef HAVE_LINUX_UINPUT_H
-int g15_init_uinput();
-void g15_uinput_keyup(unsigned char code);
-void g15_uinput_keydown(unsigned char code);
-void g15_exit_uinput();
-#endif
-
-void g15_process_keys(lcdlist_t *displaylist, unsigned int currentkeys, unsigned int lastkeys);
-
+#ifdef G15DAEMON_BUILD
/* call create_lcd for every new client, and quit it when done */
-lcd_t * create_lcd ();
-void quit_lcd (lcd_t * lcd);
-void write_buf_to_g15(lcd_t *lcd);
+lcd_t * ll_create_lcd ();
+void ll_quit_lcd (lcd_t * lcd);
+void uf_write_buf_to_g15(lcd_t *lcd);
-void setpixel (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int color);
-//void cls (lcd_t * lcd, int color);
-void line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color);
-void rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int color);
-void draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color, int num);
-
-/* utility functions in utility_func.c */
-void pthread_sleep(int seconds);
-int pthread_msleep(int milliseconds);
-
/* linked lists */
-lcdlist_t *lcdlist_init();
-void lcdlist_destroy(lcdlist_t **displaylist);
-lcdnode_t *lcdnode_add(lcdlist_t **display_list);
-void lcdnode_remove(lcdnode_t *badnode);
+lcdlist_t *ll_lcdlist_init();
+void ll_lcdlist_destroy(lcdlist_t **displaylist);
-/* create a listening socket */
-int init_sockserver();
-int g15_clientconnect(lcdlist_t **g15daemon,int listening_socket);
-int g15_send(int sock, char *buf, unsigned int len);
-int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len);
-
-/* handy function from xine_utils.c */
-void *g15_xmalloc(size_t size);
/* internal lcd plugin - the clock/menu */
int internal_clock_eventhandler(plugin_event_t *myevent);
/* generic handler for net clients */
int internal_generic_eventhandler(plugin_event_t *myevent);
+#endif
+
+void g15daemon_setpixel (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int color);
+void g15daemon_draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color, int num);
+void g15daemon_line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour);
+void g15daemon_rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int colour);
+
/* send event to foreground client's eventlistener */
-int send_event(void *caller, unsigned int event, unsigned long value);
-/* return time in milliseconds */
-unsigned int gettimerms();
+int g15daemon_send_event(void *caller, unsigned int event, unsigned long value);
+/* open named plugin */
+void * g15daemon_dlopen_plugin(char *name,unsigned int library);
+/* close plugin with handle <handle> */
+int g15daemon_dlclose_plugin(void *handle) ;
/* syslog wrapper */
int g15daemon_log (int priority, const char *fmt, ...);
+/* cycle from displayed screen to next on list */
+int g15daemon_lcdnode_cycle(lcdlist_t *displaylist);
+/* add new screen */
+lcdnode_t *g15daemon_lcdnode_add(lcdlist_t **displaylist) ;
+/* remove screen */
+void g15daemon_lcdnode_remove (lcdnode_t *oldnode);
+
+/* handy function from xine_utils.c */
+void *g15daemon_xmalloc(size_t size) ;
+/* convert 1byte/pixel buffer to internal g15 format */
+void g15daemon_convert_buf(lcd_t *lcd, unsigned char * orig_buf);
+/* load 160x43 wbmp format file into lcd struct */
+int g15daemon_load_wbmp(lcd_t *lcd, char *filename);
+/* threadsafe sleep */
+void g15daemon_sleep(int seconds);
+/* threadsafe millisecond sleep */
+int g15daemon_msleep(int milliseconds) ;
+/* return current time in milliseconds */
+unsigned int g15daemon_gettime_ms();
+
#endif
Modified: trunk/g15daemon-wip/g15daemon/gfx_primitives.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/gfx_primitives.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/gfx_primitives.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -23,6 +23,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
*/
+#define G15DAEMON_BUILD 1
#include <stdio.h>
#include <stdlib.h>
@@ -30,7 +31,7 @@
#include <libg15.h>
/* set a pixel in a libg15 buffer */
-void setpixel(lcd_t *lcd, unsigned int x, unsigned int y, unsigned int val)
+void g15daemon_setpixel(lcd_t *lcd, unsigned int x, unsigned int y, unsigned int val)
{
unsigned int curr_row = y;
unsigned int curr_col = x;
@@ -46,7 +47,7 @@
}
-void line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour) {
+void g15daemon_line (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour) {
int d, sx, sy, dx, dy;
unsigned int ax, ay;
@@ -71,7 +72,7 @@
sy = 1;
/* set the pixel */
- setpixel (lcd, x1, y1, colour);
+ g15daemon_setpixel (lcd, x1, y1, colour);
if (ax > ay)
{
@@ -85,7 +86,7 @@
}
x1 += sx;
d += ay;
- setpixel (lcd, x1, y1, colour);
+ g15daemon_setpixel (lcd, x1, y1, colour);
}
}
else
@@ -100,13 +101,13 @@
}
y1 += sy;
d += ax;
- setpixel (lcd, x1, y1, colour);
+ g15daemon_setpixel (lcd, x1, y1, colour);
}
}
}
-void rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int colour) {
+void g15daemon_rectangle (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int filled, unsigned int colour) {
int y;
@@ -114,83 +115,83 @@
{
if (!filled)
{
- line (lcd, x1, y1, x2, y1, colour);
- line (lcd, x1, y1, x1, y2, colour);
- line (lcd, x1, y2, x2, y2, colour);
- line (lcd, x2, y1, x2, y2, colour);
+ g15daemon_line (lcd, x1, y1, x2, y1, colour);
+ g15daemon_line (lcd, x1, y1, x1, y2, colour);
+ g15daemon_line (lcd, x1, y2, x2, y2, colour);
+ g15daemon_line (lcd, x2, y1, x2, y2, colour);
}
else
{
for (y = y1; y <= y2; y++)
{
- line(lcd,x1,y,x2,y,colour);
+ g15daemon_line(lcd,x1,y,x2,y,colour);
}
}
}
}
-void draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour, int num) {
+void g15daemon_draw_bignum (lcd_t * lcd, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour, int num) {
x1 += 2;
x2 -= 2;
switch(num){
case 45:
- rectangle (lcd, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1+((y2/2)-2), x2, y1+((y2/2)+2), 1, BLACK);
break;
case 46:
- rectangle (lcd, x2-5, y2-5, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x2-5, y2-5, x2, y2 , 1, BLACK);
break;
case 48:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1 +5, y1 +5, x2 -5, y2 - 6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1 +5, y1 +5, x2 -5, y2 - 6, 1, WHITE);
break;
case 49:
- rectangle (lcd, x2-5, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1, y1, x2 -5, y2, 1, WHITE);
+ g15daemon_rectangle (lcd, x2-5, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1, x2 -5, y2, 1, WHITE);
break;
case 50:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1+5, y1+((y2/2)+3), x2 , y2-6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2 , y2-6, 1, WHITE);
break;
case 51:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
break;
case 52:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1, y1+((y2/2)+3), x2 -5, y2, 1, WHITE);
- rectangle (lcd, x1+5, y1, x2-5 , y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2 -5, y2, 1, WHITE);
+ g15daemon_rectangle (lcd, x1+5, y1, x2-5 , y1+((y2/2)-3), 1, WHITE);
break;
case 53:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
break;
case 54:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1+5, y1+5, x2 , y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
break;
case 55:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1, y1+5, x2 -5, y2, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1, y1+5, x2 -5, y2, 1, WHITE);
break;
case 56:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1+5, y1+((y2/2)+3), x2-5 , y2-6, 1, WHITE);
break;
case 57:
- rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
- rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
- rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2, 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1, x2, y2 , 1, BLACK);
+ g15daemon_rectangle (lcd, x1+5, y1+5, x2-5 , y1+((y2/2)-3), 1, WHITE);
+ g15daemon_rectangle (lcd, x1, y1+((y2/2)+3), x2-5 , y2, 1, WHITE);
break;
case 58:
- rectangle (lcd, x2-5, y1+5, x2, y1+10 , 1, BLACK);
- rectangle (lcd, x2-5, y2-10, x2, y2-5 , 1, BLACK);
+ g15daemon_rectangle (lcd, x2-5, y1+5, x2, y1+10 , 1, BLACK);
+ g15daemon_rectangle (lcd, x2-5, y2-10, x2, y2-5 , 1, BLACK);
break;
}
Modified: trunk/g15daemon-wip/g15daemon/linked_lists.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/linked_lists.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/linked_lists.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -23,6 +23,8 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
*/
+#define G15DAEMON_BUILD 1
+
#include <stdio.h>
#include <stdlib.h>
#include <g15daemon.h>
@@ -32,9 +34,9 @@
extern unsigned int client_handles_keys;
extern plugin_info_t *generic_info;
-lcd_t * create_lcd () {
+lcd_t * ll_create_lcd () {
- lcd_t *lcd = g15_xmalloc (sizeof (lcd_t));
+ lcd_t *lcd = g15daemon_xmalloc (sizeof (lcd_t));
lcd->max_x = LCD_WIDTH;
lcd->max_y = LCD_HEIGHT;
lcd->backlight_state = G15_BRIGHTNESS_MEDIUM;
@@ -42,35 +44,35 @@
lcd->contrast_state = G15_CONTRAST_MEDIUM;
lcd->state_changed = 1;
lcd->usr_foreground = 0;
- lcd->g15plugin = g15_xmalloc(sizeof (plugin_s));
+ lcd->g15plugin = g15daemon_xmalloc(sizeof (plugin_s));
lcd->g15plugin->plugin_handle = NULL;
lcd->g15plugin->info = (void*)&generic_info;
return (lcd);
}
-void quit_lcd (lcd_t * lcd) {
+void ll_quit_lcd (lcd_t * lcd) {
free (lcd->g15plugin);
free (lcd);
}
/* initialise a new displaylist, and add an initial node at the tail (used for the clock) */
-lcdlist_t *lcdlist_init () {
+lcdlist_t *ll_lcdlist_init () {
lcdlist_t *displaylist = NULL;
pthread_mutex_init(&lcdlist_mutex, NULL);
pthread_mutex_lock(&lcdlist_mutex);
- displaylist = g15_xmalloc(sizeof(lcdlist_t));
+ displaylist = g15daemon_xmalloc(sizeof(lcdlist_t));
- displaylist->head = g15_xmalloc(sizeof(lcdnode_t));
+ displaylist->head = g15daemon_xmalloc(sizeof(lcdnode_t));
displaylist->tail = displaylist->head;
displaylist->current = displaylist->head;
- displaylist->head->lcd = create_lcd();
+ displaylist->head->lcd = ll_create_lcd();
displaylist->head->lcd->mkey_state = 0;
displaylist->head->lcd->masterlist = displaylist;
/* first screen is the clock/menu */
@@ -86,15 +88,15 @@
return displaylist;
}
-lcdnode_t *lcdnode_add(lcdlist_t **displaylist) {
+lcdnode_t *g15daemon_lcdnode_add(lcdlist_t **displaylist) {
lcdnode_t *new = NULL;
pthread_mutex_lock(&lcdlist_mutex);
- new = g15_xmalloc(sizeof(lcdnode_t));
+ new = g15daemon_xmalloc(sizeof(lcdnode_t));
new->prev = (*displaylist)->head;
new->next = (*displaylist)->tail;
- new->lcd = create_lcd();
+ new->lcd = ll_create_lcd();
new->lcd->masterlist = (*displaylist);
new->last_priority = NULL;
new->list = *displaylist;
@@ -112,15 +114,15 @@
}
/* cycle through connected client displays */
-int lcdnode_cycle(lcdlist_t *displaylist)
+int g15daemon_lcdnode_cycle(lcdlist_t *displaylist)
{
lcdnode_t *current_screen = displaylist->current;
- send_event(current_screen->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_HIDDEN);
+ g15daemon_send_event(current_screen->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_HIDDEN);
do
{
pthread_mutex_lock(&lcdlist_mutex);
- send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 0);
+ g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 0);
if(displaylist->tail == displaylist->current){
displaylist->current = displaylist->head;
@@ -137,15 +139,15 @@
displaylist->current = displaylist->current->prev;
}
pthread_mutex_unlock(&lcdlist_mutex);
- send_event(displaylist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE);
- send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1);
+ g15daemon_send_event(displaylist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE);
+ g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1);
pthread_mutex_lock(&lcdlist_mutex);
displaylist->current->lcd->state_changed = 1;
displaylist->current->last_priority = displaylist->current;
pthread_mutex_unlock(&lcdlist_mutex);
}
-void lcdnode_remove (lcdnode_t *oldnode) {
+void g15daemon_lcdnode_remove (lcdnode_t *oldnode) {
lcdlist_t **display_list = NULL;
lcdnode_t **prev = NULL;
@@ -157,7 +159,7 @@
prev = &oldnode->prev;
next = &oldnode->next;
- quit_lcd(oldnode->lcd);
+ ll_quit_lcd(oldnode->lcd);
(unsigned int)(*display_list)->numclients--;
if((*display_list)->current == oldnode) {
if((*display_list)->current!=(*display_list)->head){
@@ -187,12 +189,12 @@
pthread_mutex_unlock(&lcdlist_mutex);
}
-void lcdlist_destroy(lcdlist_t **displaylist) {
+void ll_lcdlist_destroy(lcdlist_t **displaylist) {
int i = 0;
while ((*displaylist)->head != (*displaylist)->tail) {
i++;
- lcdnode_remove((*displaylist)->head);
+ g15daemon_lcdnode_remove((*displaylist)->head);
}
free((*displaylist)->tail->lcd);
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/main.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -23,6 +23,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
*/
+#define G15DAEMON_BUILD 1
#include <pthread.h>
#include <stdio.h>
@@ -53,7 +54,7 @@
struct lcd_t *keyhandler = NULL;
/* send event to foreground client's eventlistener */
-int send_event(void *caller, unsigned int event, unsigned long value)
+int g15daemon_send_event(void *caller, unsigned int event, unsigned long value)
{
switch(event) {
case G15_EVENT_KEYPRESS: {
@@ -79,11 +80,11 @@
lcdlist_t* displaylist = lcd->masterlist;
static unsigned int clicktime;
if(value & cycle_key) {
- clicktime=gettimerms();
+ clicktime=g15daemon_gettime_ms();
}else{
- unsigned int unclick=gettimerms();
+ unsigned int unclick=g15daemon_gettime_ms();
if ((unclick-clicktime)<500) {
- lcdnode_cycle(displaylist);
+ g15daemon_lcdnode_cycle(displaylist);
}
else
{
@@ -107,7 +108,7 @@
lcd_t *lcd = (lcd_t*)caller;
lcdlist_t* displaylist = lcd->masterlist;
if(value)
- lcdnode_cycle(displaylist);
+ g15daemon_lcdnode_cycle(displaylist);
break;
}
case G15_EVENT_REQ_PRIORITY: {
@@ -159,10 +160,10 @@
pthread_mutex_unlock(&g15lib_mutex);
if(retval == G15_NO_ERROR){
- send_event(displaylist->current->lcd,
+ g15daemon_send_event(displaylist->current->lcd,
G15_EVENT_KEYPRESS, keypresses);
}
- pthread_msleep(10);
+ g15daemon_msleep(10);
}
return NULL;
@@ -176,7 +177,7 @@
lcd_t *displaying = displaylist->tail->lcd;
memset(displaying->buf,0,1024);
- pthread_sleep(2);
+ g15daemon_sleep(2);
while (!leaving) {
pthread_mutex_lock(&lcdlist_mutex);
@@ -184,7 +185,7 @@
displaying = displaylist->current->lcd;
if(displaying->ident != lastlcd){
- write_buf_to_g15(displaying);
+ uf_write_buf_to_g15(displaying);
lastlcd = displaying->ident;
}
@@ -197,7 +198,7 @@
pthread_mutex_unlock(&lcdlist_mutex);
- pthread_msleep(5);
+ g15daemon_msleep(5);
}
return NULL;
}
@@ -232,7 +233,7 @@
memset(daemonargs,0,20);
strncpy(daemonargs,argv[i],19);
if (!strncmp(daemonargs, "-k",2) || !strncmp(daemonargs, "--kill",6)) {
- daemonpid = g15daemon_return_running();
+ daemonpid = uf_return_running();
if(daemonpid>0) {
kill(daemonpid,SIGINT);
} else
@@ -241,13 +242,13 @@
}
if (!strncmp(daemonargs, "-v",2) || !strncmp(daemonargs, "--version",9)) {
float lg15ver = LIBG15_VERSION;
- printf("G15Daemon version %s - %s\n",VERSION,g15daemon_return_running() >= 0 ?"Loaded & Running":"Not Running");
+ printf("G15Daemon version %s - %s\n",VERSION,uf_return_running() >= 0 ?"Loaded & Running":"Not Running");
printf("compiled with libg15 version %.3f\n\n",lg15ver/1000);
exit(0);
}
if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) {
- printf("G15Daemon version %s - %s\n",VERSION,g15daemon_return_running() >= 0 ?"Loaded & Running":"Not Running");
+ 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,\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",argv[0]);
exit(0);
}
@@ -268,14 +269,14 @@
}
}
- if(g15daemon_return_running()>=0) {
+ if(uf_return_running()>=0) {
g15daemon_log(LOG_ERR,"G15Daemon already running.. Exiting");
exit(0);
}
if(!g15daemon_debug)
daemon(0,0);
- if(g15daemon_create_pidfile() == 0) {
+ if(uf_create_pidfile() == 0) {
int fd;
fd_set fds;
@@ -313,7 +314,7 @@
}
/* initialise the linked list */
- lcdlist = lcdlist_init();
+ lcdlist = ll_lcdlist_init();
lcdlist->nobody = nobody;
pthread_mutex_init(&g15lib_mutex, NULL);
pthread_attr_init(&attr);
@@ -339,8 +340,8 @@
g15daemon_log(LOG_INFO,"%s loaded\n",PACKAGE_STRING);
snprintf(location,1024,"%s/%s\0",DATADIR,"g15daemon/splash/g15logo2.wbmp");
- load_wbmp(lcdlist->tail->lcd,location);
- write_buf_to_g15(lcdlist->tail->lcd);
+ g15daemon_load_wbmp(lcdlist->tail->lcd,location);
+ uf_write_buf_to_g15(lcdlist->tail->lcd);
snprintf(location,1024,"%s/%s\0",DATADIR,"g15daemon/plugins");
@@ -366,7 +367,7 @@
exitLibG15();
#endif
#endif
- lcdlist_destroy(&lcdlist);
+ ll_lcdlist_destroy(&lcdlist);
exitnow:
/* return to root privilages for the final countdown */
Modified: trunk/g15daemon-wip/g15daemon/utility_funcs.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/utility_funcs.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/g15daemon/utility_funcs.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -23,6 +23,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
*/
+#define G15DAEMON_BUILD 1
#include <pthread.h>
#include <stdio.h>
@@ -55,7 +56,7 @@
};
/* handy function from xine_utils.c */
-void *g15_xmalloc(size_t size) {
+void *g15daemon_xmalloc(size_t size) {
void *ptr;
/* prevent xmalloc(0) of possibly returning NULL */
@@ -69,7 +70,7 @@
return ptr;
}
-int g15daemon_return_running(){
+int uf_return_running(){
int fd;
char pidtxt[128];
int pid;
@@ -101,13 +102,13 @@
}
-int g15daemon_create_pidfile() {
+int uf_create_pidfile() {
char pidtxt[128];
size_t l;
int fd;
- if(!g15daemon_return_running() && (fd = open(G15DAEMON_PIDFILE, O_CREAT|O_RDWR|O_EXCL, 0644)) < 0) {
+ if(!uf_return_running() && (fd = open(G15DAEMON_PIDFILE, O_CREAT|O_RDWR|O_EXCL, 0644)) < 0) {
g15daemon_log(LOG_ERR,"previous G15Daemon process died. removing pidfile");
unlink(G15DAEMON_PIDFILE);
}
@@ -146,16 +147,16 @@
return 0;
}
-void convert_buf(lcd_t *lcd, unsigned char * orig_buf)
+void g15daemon_convert_buf(lcd_t *lcd, unsigned char * orig_buf)
{
unsigned int x,y;
for(x=0;x<160;x++)
for(y=0;y<43;y++)
- setpixel(lcd,x,y,orig_buf[x+(y*160)]);
+ g15daemon_setpixel(lcd,x,y,orig_buf[x+(y*160)]);
}
/* wrap the libg15 function */
-void write_buf_to_g15(lcd_t *lcd)
+void uf_write_buf_to_g15(lcd_t *lcd)
{
pthread_mutex_lock(&g15lib_mutex);
writePixmapToLCD(lcd->buf);
@@ -164,7 +165,7 @@
}
/* basic wbmp loader - wbmps should be inverted for use here */
-int load_wbmp(lcd_t *lcd, char *filename)
+int g15daemon_load_wbmp(lcd_t *lcd, char *filename)
{
int wbmp_fd;
int retval;
@@ -206,7 +207,7 @@
/* Sleep routine (hackish). */
-void pthread_sleep(int seconds) {
+void g15daemon_sleep(int seconds) {
pthread_mutex_t dummy_mutex;
static pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER;
struct timespec timeout;
@@ -226,7 +227,7 @@
}
/* millisecond sleep routine. */
-int pthread_msleep(int milliseconds) {
+int g15daemon_msleep(int milliseconds) {
struct timespec timeout;
if(milliseconds>999)
@@ -237,7 +238,7 @@
return nanosleep (&timeout, NULL);
}
-unsigned int gettimerms(){
+unsigned int g15daemon_gettime_ms(){
struct timeval tv;
gettimeofday(&tv,NULL);
return (tv.tv_sec*1000+tv.tv_usec/1000);
Modified: trunk/g15daemon-wip/plugins/g15_plugin_clock.c
===================================================================
--- trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -64,7 +64,7 @@
for (col=0;col<len;col++)
{
- draw_bignum (lcd, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, LCD_HEIGHT, BLACK, buf[col]);
+ g15daemon_draw_bignum (lcd, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, LCD_HEIGHT, BLACK, buf[col]);
}
lcd->ident = currtime+100;
Modified: trunk/g15daemon-wip/plugins/g15_plugin_net.c
===================================================================
--- trunk/g15daemon-wip/plugins/g15_plugin_net.c 2006-11-13 03:14:20 UTC (rev 131)
+++ trunk/g15daemon-wip/plugins/g15_plugin_net.c 2006-11-13 05:25:42 UTC (rev 132)
@@ -248,7 +248,7 @@
}
pthread_mutex_lock(&lcdlist_mutex);
memset(client_lcd->buf,0,1024);
- convert_buf(client_lcd,tmpbuf);
+ g15daemon_convert_buf(client_lcd,tmpbuf);
client_lcd->ident = random();
pthread_mutex_unlock(&lcdlist_mutex);
}
@@ -301,7 +301,7 @@
exitthread:
close(client_sock);
free(tmpbuf);
- lcdnode_remove(display);
+ g15daemon_lcdnode_remove(display);
pthread_exit(NULL);
}
@@ -332,7 +332,7 @@
}
}
- clientnode = lcdnode_add(g15daemon);
+ clientnode = g15daemon_lcdnode_add(g15daemon);
clientnode->lcd->connection = conn_s;
/* override the default (generic handler and use our own for our clients */
clientnode->lcd->g15plugin->info=(void*)(&lcdclient_info);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|