summary refs log blame commit diff stats
path: root/plugins/mpcinfo/mpcInfo.c
blob: e467e51621e75ccb3012c69e32ad43148d33984c (plain) (tree)




















































































































































                                                                                                                             
/*
 *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

//static int DEBUG=0;
static char *VERSION="0.0.6";

#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include "xchat-plugin.h"
static xchat_plugin *ph;

#include "functions.c"
#include "mp3Info.c"
#include "oggInfo.c"
#include "theme.c"

static int print_themes (char *word[], char *word_eol[], void *userdata){
       printThemes();
       return XCHAT_EAT_ALL;
}

static int mpc_themeReload(char *word[], char *word_eol[], void *userdata){
   themeInit();
   loadThemes();
   return XCHAT_EAT_ALL;
}

static int mpc_tell(char *word[], char *word_eol[], void *userdata){
       char *tTitle, *zero, *oggLine, *line;
	   struct tagInfo info;
	   HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
       if (hwnd==0) {xchat_command(ph, randomLine(notRunTheme));return XCHAT_EAT_ALL;}
       
       tTitle=(char*)malloc(sizeof(char)*1024);
       GetWindowText(hwnd, tTitle, 1024);
       zero=strstr(tTitle," - Media Player Classic");
       if (zero!=NULL) zero[0]=0;
       else xchat_print(ph,"pattern not found");
       
       if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
          //xchat_print(ph,"seams to be full path");
          if (endsWith(tTitle,".mp3")==1){
             //xchat_print(ph,"seams to be a mp3 file");
             info = readHeader(tTitle);
             
             if ((info.artist!=NULL)&&(strcmp(info.artist,"")!=0)){
                char *mode=MODES[info.mode];
                //xchat_printf(ph,"mode: %s\n",mode);
                char *mp3Line=randomLine(mp3Theme);
                mp3Line=replace(mp3Line,"%art",info.artist);
                mp3Line=replace(mp3Line,"%tit",info.title);
                mp3Line=replace(mp3Line,"%alb",info.album);
                mp3Line=replace(mp3Line,"%com",info.comment);
                mp3Line=replace(mp3Line,"%gen",info.genre);
                //mp3Line=replace(mp3Line,"%time",pos);
                //mp3Line=replace(mp3Line,"%length",len);
                //mp3Line=replace(mp3Line,"%ver",waVers);
                //mp3Line=intReplace(mp3Line,"%br",br);
                //mp3Line=intReplace(mp3Line,"%frq",frq);
                
                mp3Line=intReplace(mp3Line,"%br",info.bitrate);
                mp3Line=intReplace(mp3Line,"%frq",info.freq);
                mp3Line=replace(mp3Line,"%mode",mode);
                //mp3Line=replace(mp3Line,"%size",size);
                //mp3Line=intReplace(mp3Line,"%perc",perc);
                //mp3Line=replace(mp3Line,"%plTitle",title);
                mp3Line=replace(mp3Line,"%file",tTitle);
                xchat_command(ph, mp3Line);
                return XCHAT_EAT_ALL;
             }
          }
          if (endsWith(tTitle,".ogg")==1){
             xchat_printf(ph,"Ogg detected\n");
             info = getOggHeader(tTitle);
             if (info.artist!=NULL){
                char *cbr;
                if (info.cbr==1) cbr="CBR"; else cbr="VBR";
                oggLine=randomLine(oggTheme);
                //if (cue==1) oggLine=cueLine;
                //xchat_printf(ph,"ogg-line: %s\n",oggLine);
                oggLine=replace(oggLine,"%art",info.artist);
                oggLine=replace(oggLine,"%tit",info.title);
                oggLine=replace(oggLine,"%alb",info.album);
                oggLine=replace(oggLine,"%com",info.comment);
                oggLine=replace(oggLine,"%gen",info.genre);
                //oggLine=replace(oggLine,"%time",pos);
                //oggLine=replace(oggLine,"%length",len);
                //oggLine=replace(oggLine,"%ver",waVers);
                oggLine=intReplace(oggLine,"%chan",info.mode);
                oggLine=replace(oggLine,"%cbr",cbr);
                oggLine=intReplace(oggLine,"%br",info.bitrate/1000);//br);
                oggLine=intReplace(oggLine,"%frq",info.freq);
                //oggLine=replace(oggLine,"%size",size);
                //oggLine=intReplace(oggLine,"%perc",perc);
                //oggLine=replace(oggLine,"%plTitle",title);
                oggLine=replace(oggLine,"%file",tTitle);
                xchat_command(ph, oggLine);
                return XCHAT_EAT_ALL;
             }
          }
       }
       line=randomLine(titleTheme);
       line=replace(line,"%title", tTitle);
       xchat_command(ph,line); 
       return XCHAT_EAT_ALL;
}

int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg){
	ph = plugin_handle;
	*plugin_name = "mpcInfo";
	*plugin_desc = "Information-Script for Media Player Classic"; 
	*plugin_version=VERSION;

	xchat_hook_command(ph, "mpc", XCHAT_PRI_NORM, mpc_tell,"no help text", 0);
	xchat_hook_command(ph, "mpc_themes", XCHAT_PRI_NORM, print_themes,"no help text", 0);
	xchat_hook_command(ph, "mpc_reloadthemes", XCHAT_PRI_NORM, mpc_themeReload,"no help text", 0);
	xchat_command (ph, "MENU -ietc\\music.png ADD \"Window/Display Current Song (MPC)\" \"MPC\"");

	themeInit();
	loadThemes();
	xchat_printf(ph, "%s %s plugin loaded\n",*plugin_name, VERSION);

	return 1;
}

int
xchat_plugin_deinit (void)
{
	xchat_command (ph, "MENU DEL \"Window/Display Current Song (MPC)\"");
	xchat_print (ph, "mpcInfo plugin unloaded\n");
	return 1;
}

                                                         
                                               
                           
                                 

                                                      
                                 

                                                                  
                                              

                                                                  
                                              

                                                                  
                                              

                                                               
                                          

                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                    
                                                     


                                                                  
                      

                            
                         
                                   
                                   
                                


                                                     










                                                          
                                                 






                                                          


                                                                                                     

                                           
                                               





















                                                                                             




                                                                      
                                                          
                                                      
                                                          





                                                           
                                                         
                                                          
                                                       
                                                 
                                                            

                                                                            
                       
                   


                        
                                          


                         


                          
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros">
    <!-- SPECIFY YOUR DEPENDENCY DIRECTORIES HERE -->
    <YourDepsPath>c:\mozilla-build\hexchat\build</YourDepsPath>
    <YourGendefPath>c:\mozilla-build\gendef</YourGendefPath>
    <YourMsgfmtPath>c:\mozilla-build\msgfmt</YourMsgfmtPath>
    <YourTclPath>c:\mozilla-build\tcl-8.5</YourTclPath>
    <YourPerl512Path>c:\mozilla-build\perl-5.12</YourPerl512Path>
    <YourPerl514Path>c:\mozilla-build\perl-5.14</YourPerl514Path>
    <YourPerl516Path>c:\mozilla-build\perl-5.16</YourPerl516Path>
    <YourPythonPath>c:\mozilla-build\python-2.7</YourPythonPath>
    <!-- YOU SHOULDN'T TOUCH ANYTHING BELOW -->
	<!-- G_DISABLE_DEPRECATED is unfeasible due to g_completion_* -->
    <OwnFlags>G_DISABLE_CAST_CHECKS;GDK_PIXBUF_DISABLE_DEPRECATED;GDK_DISABLE_DEPRECATED;HAVE_STRTOULL;strtoull=_strtoui64;strcasecmp=stricmp;strncasecmp=strnicmp;__inline__=__inline;</OwnFlags>
    <DepsRoot>$(YourDepsPath)\$(PlatformName)</DepsRoot>
    <GendefPath>$(YourGendefPath)</GendefPath>
    <MsgfmtPath>$(YourMsgfmtPath)</MsgfmtPath>
    <LuaLib>lua51</LuaLib>
    <LuaOutput>hclua</LuaOutput>
    <TclPath>$(YourTclPath)\$(PlatformName)</TclPath>
    <TclLib>tcl85</TclLib>
    <TclOutput>hctcl</TclOutput>
    <Perl512Path>$(YourPerl512Path)\$(PlatformName)</Perl512Path>
    <Perl512Lib>perl512</Perl512Lib>
    <Perl512Output>hcperl-512</Perl512Output>
    <Perl514Path>$(YourPerl514Path)\$(PlatformName)</Perl514Path>
    <Perl514Lib>perl514</Perl514Lib>
    <Perl514Output>hcperl-514</Perl514Output>
    <Perl516Path>$(YourPerl516Path)\$(PlatformName)</Perl516Path>
    <Perl516Lib>perl516</Perl516Lib>
    <Perl516Output>hcperl-516</Perl516Output>
    <PythonPath>$(YourPythonPath)\$(PlatformName)</PythonPath>
    <PythonLib>python27</PythonLib>
    <PythonOutput>hcpython</PythonOutput>
    <Glib>$(DepsRoot)\include\glib-2.0;$(DepsRoot)\lib\glib-2.0\include;$(DepsRoot)\include\libxml2</Glib>
    <Gtk>$(DepsRoot)\include\gtk-2.0;$(DepsRoot)\lib\gtk-2.0\include;$(DepsRoot)\include\atk-1.0;$(DepsRoot)\include\cairo;$(DepsRoot)\include\pango-1.0;$(DepsRoot)\include\gdk-pixbuf-2.0</Gtk>
    <Pixmaps>bookpng "$(SolutionDir)\..\src\pixmaps\book.png" hoppng "$(SolutionDir)\..\src\pixmaps\hop.png" oppng "$(SolutionDir)\..\src\pixmaps\op.png" orangepng "$(SolutionDir)\..\src\pixmaps\orange.png" purplepng "$(SolutionDir)\..\src\pixmaps\purple.png" redpng "$(SolutionDir)\..\src\pixmaps\red.png" trayfilepng "$(SolutionDir)\..\src\pixmaps\fileoffer.png" trayhilightpng "$(SolutionDir)\..\src\pixmaps\highlight.png" traymsgpng "$(SolutionDir)\..\src\pixmaps\message.png" voicepng "$(SolutionDir)\..\src\pixmaps\voice.png" channelpng "$(SolutionDir)\..\src\pixmaps\channel.png" dialogpng "$(SolutionDir)\..\src\pixmaps\dialog.png" serverpng "$(SolutionDir)\..\src\pixmaps\server.png" utilpng "$(SolutionDir)\..\src\pixmaps\util.png" hexchatpng "$(SolutionDir)\..\hexchat.png"</Pixmaps>
    <DepLibs>gtk-win32-2.0.lib;gdk-win32-2.0.lib;atk-1.0.lib;gio-2.0.lib;gdk_pixbuf-2.0.lib;pangowin32-1.0.lib;pangocairo-1.0.lib;pango-1.0.lib;cairo.lib;gobject-2.0.lib;gmodule-2.0.lib;glib-2.0.lib;libintl.lib;libxml2.lib;libeay32.lib;ssleay32.lib;wininet.lib;winmm.lib;ws2_32.lib</DepLibs>
    <HexChatBuild>$(SolutionDir)build</HexChatBuild>
    <HexChatBin>$(HexChatBuild)\$(PlatformName)\bin\</HexChatBin>
    <HexChatObj>$(HexChatBuild)\$(PlatformName)\obj\</HexChatObj>
    <HexChatRel>$(HexChatBuild)\$(PlatformName)\rel</HexChatRel>
	<HexChatCopy>
rmdir /q /s "$(HexChatRel)"
mkdir "$(HexChatRel)"
echo 2&gt; portable-mode
move portable-mode "$(HexChatRel)"
copy changelog.url "$(HexChatRel)"
copy readme.url "$(HexChatRel)"
copy "$(HexChatBin)hexchat.exe" "$(HexChatRel)"
copy "$(HexChatBin)hexchat-text.exe" "$(HexChatRel)"
copy "$(HexChatBin)thememan.exe" "$(HexChatRel)"
copy "$(DepsRoot)\bin\atk-1.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\cairo.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\fontconfig.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gdk_pixbuf-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gdk-win32-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gio-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\glib-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gmodule-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gobject-2.0.dll" "$(HexChatRel)
copy "$(DepsRoot)\bin\gthread-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\gtk-win32-2.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\iconv.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\libintl.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\libpng15.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\libxml2.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\pango-1.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\pangocairo-1.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\pangoft2-1.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\pangowin32-1.0.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\pixman-1.dll" "$(HexChatRel)"
::xcopy /q /s /i "$(DepsRoot)\lib\gtk-2.0\2.10.0\engines" "$(HexChatRel)\lib\gtk-2.0\2.10.0\engines"
::xcopy /q /s /i "$(DepsRoot)\lib\gtk-2.0\modules\libgail.dll" "$(HexChatRel)\lib\gtk-2.0\modules\"
xcopy /q /s /i etc "$(HexChatRel)\etc"
xcopy /q /s /i share "$(HexChatRel)\share"
copy "..\..\share\doc\COPYING" "$(HexChatRel)"
copy "$(DepsRoot)\LICENSE.ATK" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.CAIRO" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.ENCHANT" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.FONTCONFIG" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.FREETYPE" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.GDKPIXBUF" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.GETTEXT" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.GLIB" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.GTK" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.LIBFFI" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.LIBPNG" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.LIBXML2" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.OPENSSL" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.PANGO" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.PIXMAN" "$(HexChatRel)\share"
copy "$(DepsRoot)\LICENSE.ZLIB" "$(HexChatRel)\share"
copy "$(DepsRoot)\bin\libeay32.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\ssleay32.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\zlib1.dll" "$(HexChatRel)"
copy "$(DepsRoot)\bin\cert.pem" "$(HexChatRel)"
copy "$(DepsRoot)\bin\libenchant.dll" "$(HexChatRel)"
xcopy /q /s /i "$(DepsRoot)\lib\enchant\libenchant_myspell.dll" "$(HexChatRel)\lib\enchant\"
xcopy /q /s /i "$(HexChatBin)hcchecksum.dll" "$(HexChatRel)\plugins\"
copy "$(HexChatBin)hcdns.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcdoat.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcexec.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcfishlim.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hchextray.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hclua.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcmpcinfo.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcperl-512.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcperl-514.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcperl-516.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcpython.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hctcl.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcupd.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcwinamp.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcsysinfo.dll" "$(HexChatRel)\plugins"
copy "$(HexChatBin)hcwmpa.dll" "$(HexChatRel)\plugins"
copy "$(DepsRoot)\bin\lua51.dll" "$(HexChatRel)"
xcopy /q /s /i "$(HexChatBin)locale" "$(HexChatRel)\locale"
xcopy /q /s /i "$(DepsRoot)\share\locale" "$(HexChatRel)\share\locale"
copy "$(ProgramFiles)\Codejock Software\ISSkin\ISSkinU.dll" "$(HexChatRel)"
	</HexChatCopy>
  </PropertyGroup>

  <ItemDefinitionGroup>
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
    </ClCompile>
  </ItemDefinitionGroup>

  <ItemDefinitionGroup />
  <ItemGroup />
</Project>