Attached is a patch that implements rudimentary LIRC support.  I didn't do
any of the autoconf stuff to enable/disable the feature, since I'm still
learning that stuff.

(This patch is against the CVS tree as of Jul 26 2001, since the only file
touched outside the new plugin is Makefile-plugins.in that really shouldn't
matter)

Jeff
-- 
----------------------------------------------------------------------------
It may well be doubted whether human ingenuity can construct an enigma of the 
kind which human ingenuity may not, by proper application, resolve.
        Edger Allen Poe
----------------------------------------------------------------------------
diff -ur --new-file freeamp/Makefile-plugins.in freeamp.lirc/Makefile-plugins.in
--- freeamp/Makefile-plugins.in Tue Apr 10 16:54:47 2001
+++ freeamp.lirc/Makefile-plugins.in    Thu Jul 26 19:56:05 2001
@@ -29,7 +29,7 @@
 OSDEPPLUGINS = @OSDEPPLUGINS@
 
 clean-plugins plugins-clean:
-       -rm -f $(CORBAUIOBJ) $(VORBISLIBOBJ) $(VORBISOBJ) $(VORBISMDFOBJ) 
$(SIGNATUREPMOOBJ) $(LIBHTTPOBJ) $(KJOFOLOBJ) $(WINAMPOBJ) $(CDPMOOBJ) $(CDLMCOBJ) 
$(UNZIPOBJ) $(MBCDOBJ) $(PLSOBJ) $(RMPOBJ) $(MISCOBJ) $(ZLIBOBJ) $(MUSICBROWSEROBJ) 
$(MAKETHEMEOBJ) $(LFIOBJ) $(HTTPOBJ) $(OBSPMI) $(SCPMOOBJ) $(ALSAOBJ) $(ESNDOBJ) 
$(DOWNLOADUIOBJ) $(CMDUIOBJ) $(MPG123UIOBJ) $(NCURSESUIOBJ) $(LCDUIOBJ) $(IRMANUIOBJ) 
$(FREEAMPUIOBJ) $(ID3V1OBJ) $(ID3V2OBJ) $(M3UOBJ) $(PMP300OBJ) $(XINGLMCOBJ) 
$(WAVPMOOBJ) MakeTheme plugins/*.*
+       -rm -f $(CORBAUIOBJ) $(VORBISLIBOBJ) $(VORBISOBJ) $(VORBISMDFOBJ) 
+$(SIGNATUREPMOOBJ) $(LIBHTTPOBJ) $(KJOFOLOBJ) $(WINAMPOBJ) $(CDPMOOBJ) $(CDLMCOBJ) 
+$(UNZIPOBJ) $(MBCDOBJ) $(PLSOBJ) $(RMPOBJ) $(MISCOBJ) $(ZLIBOBJ) $(MUSICBROWSEROBJ) 
+$(MAKETHEMEOBJ) $(LFIOBJ) $(HTTPOBJ) $(OBSPMI) $(SCPMOOBJ) $(ALSAOBJ) $(ESNDOBJ) 
+$(DOWNLOADUIOBJ) $(CMDUIOBJ) $(MPG123UIOBJ) $(NCURSESUIOBJ) $(LCDUIOBJ) $(IRMANUIOBJ) 
+$(FREEAMPUIOBJ) $(ID3V1OBJ) $(ID3V2OBJ) $(M3UOBJ) $(PMP300OBJ) $(XINGLMCOBJ) 
+$(WAVPMOOBJ) $(LIRCOBJ) MakeTheme plugins/*.*
 
 PLUGINS =  lib/zlib/lib/libzlib.la
 PLUGINS += lib/unzip/lib/libunzip.la
@@ -292,6 +292,12 @@
 plugins/irman.ui: $(IRMANUIOBJ)
        $(LINKMOD) -o $@ $(IRMANUIOBJ) $(STATICLD)
 
+# LIRC
+LIRCOBJ = ui/lirc/lircui.o
+
+plugins/lirc.ui: $(LIRCOBJ)
+       $(LINKMOD) -o $@ $(LIRCOBJ) -llirc_client $(STATICLD)
+
 CORBAUIOBJ  = ui/corba/Freeamp-common.o ui/corba/corbaUI.o ui/corba/corba.o
 CORBAUIOBJ += ui/corba/Freeamp-skels.o
 
@@ -517,6 +523,6 @@
        $(LIBMOD) $@ $(LIBHTTPOBJ)
 
 depend:
-       makedepend -fMakefile-plugins -- $(DEFS) -I/usr/include/g++-3 $(INCLUDES) 
$(CFLAGS) -- `echo $(CORBAUIOBJ) $(VORBISMDFOBJ) $(WAVPMOOBJ) $(VORBISLIBOBJ) 
$(VORBISOBJ) $(SIGNATUREPMOOBJ) $(KJOFOLOBJ) $(LIBHTTPOBJ) $(UNZIPOBJ) $(WINAMPOBJ) 
$(LFIOBJ) $(DOWNLOADUIOBJ) $(CDPMOOBJ) $(CDLMCOBJ) $(THEMEUIOBJ) $(MUSICBROWSEROBJ) 
$(HTTPOBJ) $(SCPMOOBJ) $(ALSAOBJ) $(ESNDOBJ) $(CMDUIOBJ) $(MPG123UIOBJ) 
$(NCURSESUIOBJ) $(LCDUIOBJ) $(IRMANUIOBJ) $(GTKUIOBJ) $(FREEAMPUIOBJ) $(XINGLMCOBJ) 
$(PMP300OBJ) $(M3UOBJ) $(ID3V1OBJ) $(ID3V2OBJ) | sed -e 's,\.o,.cpp,g' | sed -e 
's,\.doh,.cpp,g'`
+       makedepend -fMakefile-plugins -- $(DEFS) -I/usr/include/g++-3 $(INCLUDES) 
+$(CFLAGS) -- `echo $(CORBAUIOBJ) $(VORBISMDFOBJ) $(WAVPMOOBJ) $(VORBISLIBOBJ) 
+$(VORBISOBJ) $(SIGNATUREPMOOBJ) $(KJOFOLOBJ) $(LIBHTTPOBJ) $(UNZIPOBJ) $(WINAMPOBJ) 
+$(LFIOBJ) $(DOWNLOADUIOBJ) $(CDPMOOBJ) $(CDLMCOBJ) $(THEMEUIOBJ) $(MUSICBROWSEROBJ) 
+$(HTTPOBJ) $(SCPMOOBJ) $(ALSAOBJ) $(ESNDOBJ) $(CMDUIOBJ) $(MPG123UIOBJ) 
+$(NCURSESUIOBJ) $(LCDUIOBJ) $(IRMANUIOBJ) $(GTKUIOBJ) $(FREEAMPUIOBJ) $(XINGLMCOBJ) 
+$(PMP300OBJ) $(M3UOBJ) $(ID3V1OBJ) $(ID3V2OBJ) $(LIRCOBJ)| sed -e 's,\.o,.cpp,g' | 
+sed -e 's,\.doh,.cpp,g'`
  
 # DO NOT DELETE THIS LINE -- make depend depends on it.
diff -ur --new-file freeamp/ui/lirc/lircui.cpp freeamp.lirc/ui/lirc/lircui.cpp
--- freeamp/ui/lirc/lircui.cpp  Wed Dec 31 17:00:00 1969
+++ freeamp.lirc/ui/lirc/lircui.cpp     Thu Jul 26 20:25:30 2001
@@ -0,0 +1,155 @@
+/*____________________________________________________________________________
+        
+        FreeAmp - The Free MP3 Player
+
+        Copyright (C) 2001 Jeffrey McBeth
+
+        This program is free software; you can redistribute it and/or modify
+        it under the terms of the GNU General Public License as published by
+        the Free Software Foundation; either version 2 of the License, or
+        (at your option) any later version.
+
+        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 General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this program; if not, write to the Free Software
+        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+        
+lirc interface by Jeffrey McBeth ([EMAIL PROTECTED])
+
+____________________________________________________________________________*/
+
+#include <iostream>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <sys/time.h>
+#include <termios.h>
+#include <signal.h>
+
+#include "config.h"
+#include "lircui.h"
+#include "event.h"
+#include "playlist.h"
+#include "thread.h"
+#include "eventdata.h"
+
+#define stdinfd 0
+
+extern "C" {
+
+UserInterface *Initialize(FAContext *context) {
+    return new lircUI(context);
+}
+
+           }
+          
+lircUI::lircUI(FAContext *context) {
+    m_context = context;
+    m_playerEQ = NULL;
+    lircListenThread = NULL;
+}
+
+Error lircUI::Init(int32 startup_level) {
+
+  if (lirc_init("freeamp",0) == -1)
+    return kError_PluginNotInitialized;
+  if (lirc_readconfig(NULL, &config, NULL) == -1)
+    return kError_PluginNotInitialized;
+  m_playerEQ = m_context->target;
+
+  lircListenThread = Thread::CreateThread();
+  lircListenThread->Create(lircUI::lircServiceFunction,this);
+
+  return kError_NoErr;
+}
+
+lircUI::~lircUI() {
+  if (lircListenThread) {
+    lircListenThread->Destroy();
+    delete lircListenThread;
+    lircListenThread = NULL;
+  }
+
+  lirc_freeconfig(config);
+  lirc_deinit();
+}
+
+void lircUI::lircServiceFunction(void *pclcio) {
+    lircUI *pMe = (lircUI *)pclcio;
+    char *code, *command;
+
+    for (;;) {
+      if (lirc_nextcode(&code) == -1)
+       {
+         printf("Closed Socket\n");
+         return;
+       }
+
+      if (code == NULL)
+       continue;
+
+      if (lirc_code2char(pMe->config,code,&command) == -1)
+      {
+       continue;
+      }
+
+      while(command)
+      {
+
+        if (strncasecmp(command, "PLAY", 5) == 0)
+        {
+          Event *e = new Event(CMD_Play);
+          pMe->m_playerEQ->AcceptEvent(e);
+        }
+        else if (strncasecmp(command, "STOP", 5) == 0)
+        {
+          Event *e = new Event(CMD_Stop);
+          pMe->m_playerEQ->AcceptEvent(e);
+        }
+        else if (strncasecmp(command, "PAUSE", 5) == 0)
+        {
+          Event *e = new Event(CMD_TogglePause);
+          pMe->m_playerEQ->AcceptEvent(e);
+        }
+        else if (strncasecmp(command, "NEXT", 4) == 0)
+        {
+          Event *e = new Event(CMD_NextMediaPiece);
+          pMe->m_playerEQ->AcceptEvent(e);
+        }
+        else if (strncasecmp(command, "PREV", 4) == 0)
+        {
+          Event *e = new Event(CMD_PrevMediaPiece);
+          pMe->m_playerEQ->AcceptEvent(e);
+        }
+
+       lirc_code2char(pMe->config,code,&command);
+
+      }
+      
+      delete code;
+    }
+    
+}
+
+Error lircUI::AcceptEvent(Event *e) {
+  if (e) {
+    switch (e->Type()) {
+    case INFO_PlaylistDonePlay: {
+      Event *e = new Event(CMD_QuitPlayer);
+      m_playerEQ->AcceptEvent(e);
+      break; }
+    case CMD_Cleanup: {
+      Event *e = new Event(INFO_ReadyToDieUI);
+      m_playerEQ->AcceptEvent(e);
+      break; }
+    default:
+      break;
+    }
+  }
+  return kError_NoErr;
+}
+
diff -ur --new-file freeamp/ui/lirc/lircui.h freeamp.lirc/ui/lirc/lircui.h
--- freeamp/ui/lirc/lircui.h    Wed Dec 31 17:00:00 1969
+++ freeamp.lirc/ui/lirc/lircui.h       Thu Jul 26 20:25:51 2001
@@ -0,0 +1,64 @@
+/*____________________________________________________________________________
+       
+       FreeAmp - The Free MP3 Player
+
+
+       Copyright (C) 2001 Jeffrey McBeth
+
+       This program is free software; you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation; either version 2 of the License, or
+       (at your option) any later version.
+
+       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 General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to the Free Software
+       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    lirc interface by Jeffrey McBeth ([EMAIL PROTECTED])
+
+       $Id$
+____________________________________________________________________________*/
+
+#ifndef INCLUDED_LIRCUI_H_
+#define INCLUDED_LIRCUI_H_
+
+#include <lirc/lirc_client.h>
+
+#include "ui.h"
+#include "event.h"
+#include "thread.h"
+#include "playlist.h"
+#include "eventdata.h"
+
+class FAContext;
+
+class lircUI : public UserInterface {
+ public:
+    lircUI(FAContext *context);
+    virtual Error AcceptEvent(Event *);
+    virtual Error Init(int32);
+    static void lircServiceFunction(void *);
+    virtual ~lircUI();
+
+ protected:
+   FAContext *m_context;
+
+ private:
+   lirc_config *config;
+   
+   EventQueue *m_playerEQ;
+
+   Thread *lircListenThread;
+};
+
+
+#endif // _LIRC_H_
+
+
+
+

Reply via email to