├── .gitignore ├── ABOUT-NLS ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── autogen.sh ├── config.rpath ├── configure.ac ├── dailydeb.sh.in ├── data ├── Makefile.am ├── dialogs.glade ├── icons │ └── osdlyric │ │ ├── 128x128 │ │ └── osdlyric.png │ │ ├── 22x22 │ │ └── osdlyric.png │ │ ├── 32x32 │ │ └── osdlyric.png │ │ ├── 48x48 │ │ └── osdlyric.png │ │ └── 64x64 │ │ └── osdlyric.png ├── osdlyrics-loading.png ├── osdlyrics-osd-bg.svg ├── osdlyrics-osd-next.svg ├── osdlyrics-osd-pause.svg ├── osdlyrics-osd-play.svg ├── osdlyrics-osd-prev.svg ├── osdlyrics-osd-stop.svg ├── osdlyrics-scroll-close.svg ├── osdlyrics-trayicon.png ├── osdlyrics.desktop └── osdlyrics.png ├── install-sh ├── lib ├── Makefile.am └── chardetect │ ├── MPL-1.1.txt │ ├── Makefile.am │ ├── README │ ├── include │ └── chardetect.h │ ├── src │ ├── CharDistribution.cpp │ ├── CharDistribution.h │ ├── JpCntx.cpp │ ├── JpCntx.h │ ├── LangBulgarianModel.cpp │ ├── LangCyrillicModel.cpp │ ├── LangGreekModel.cpp │ ├── LangHebrewModel.cpp │ ├── LangHungarianModel.cpp │ ├── LangThaiModel.cpp │ ├── Makefile │ ├── entry │ │ ├── export-symbol.list │ │ └── impl.cpp │ ├── nsBig5Prober.cpp │ ├── nsBig5Prober.h │ ├── nsCharSetProber.cpp │ ├── nsCharSetProber.h │ ├── nsCodingStateMachine.h │ ├── nsEUCJPProber.cpp │ ├── nsEUCJPProber.h │ ├── nsEUCKRProber.cpp │ ├── nsEUCKRProber.h │ ├── nsEUCTWProber.cpp │ ├── nsEUCTWProber.h │ ├── nsEscCharsetProber.cpp │ ├── nsEscCharsetProber.h │ ├── nsEscSM.cpp │ ├── nsGB2312Prober.cpp │ ├── nsGB2312Prober.h │ ├── nsHebrewProber.cpp │ ├── nsHebrewProber.h │ ├── nsLatin1Prober.cpp │ ├── nsLatin1Prober.h │ ├── nsMBCSGroupProber.cpp │ ├── nsMBCSGroupProber.h │ ├── nsMBCSSM.cpp │ ├── nsPkgInt.h │ ├── nsSBCSGroupProber.cpp │ ├── nsSBCSGroupProber.h │ ├── nsSBCharSetProber.cpp │ ├── nsSBCharSetProber.h │ ├── nsSJISProber.cpp │ ├── nsSJISProber.h │ ├── nsUTF8Prober.cpp │ ├── nsUTF8Prober.h │ ├── nsUniversalDetector.cpp │ ├── nsUniversalDetector.h │ ├── nscore.h │ ├── prmem.h │ └── tables │ │ ├── Big5Freq.tab │ │ ├── EUCKRFreq.tab │ │ ├── EUCTWFreq.tab │ │ ├── GB2312Freq.tab │ │ └── JISFreq.tab │ └── test │ ├── Makefile │ └── test-chardetect.c ├── m4 ├── ChangeLog ├── gettext.m4 ├── iconv.m4 ├── lib-ld.m4 ├── lib-link.m4 ├── lib-prefix.m4 ├── nls.m4 ├── po.m4 └── progtest.m4 ├── packsrc.sh ├── po ├── ChangeLog ├── LINGUAS ├── Makefile.in.in ├── Makevars ├── POTFILES.in ├── Rules-quot ├── boldquot.sed ├── de.po ├── en@boldquot.header ├── en@quot.header ├── es.po ├── fr.po ├── insert-header.sin ├── it.po ├── ms.po ├── osdlyrics.pot ├── pt_BR.po ├── quot.sed ├── remove-potcdate.sin ├── ro.po ├── ru.po ├── stamp-po ├── tr.po ├── uk.po ├── zh_CN.po ├── zh_HK.po └── zh_TW.po └── src ├── Makefile.am ├── genmarshal.sh ├── gettext.h ├── marshal ├── ol_about.c ├── ol_about.h ├── ol_app.h ├── ol_app_chooser_widget.c ├── ol_app_chooser_widget.h ├── ol_app_info.c ├── ol_app_info.h ├── ol_cell_renderer_button.c ├── ol_cell_renderer_button.h ├── ol_color.c ├── ol_color.h ├── ol_commands.c ├── ol_commands.h ├── ol_config.c ├── ol_config.h ├── ol_config_property.h ├── ol_debug.c ├── ol_debug.h ├── ol_display_module.c ├── ol_display_module.h ├── ol_eggaccelerators.c ├── ol_eggaccelerators.h ├── ol_elapse_emulator.c ├── ol_elapse_emulator.h ├── ol_fork.c ├── ol_fork.h ├── ol_gui.c ├── ol_gui.h ├── ol_gussian_blur.c ├── ol_gussian_blur.h ├── ol_image_button.c ├── ol_image_button.h ├── ol_intl.h ├── ol_keybinder.c ├── ol_keybinder.h ├── ol_keybinding_settings.h ├── ol_keybindings.c ├── ol_keybindings.h ├── ol_lrc.c ├── ol_lrc.h ├── ol_lrc_candidate_list.c ├── ol_lrc_candidate_list.h ├── ol_lrc_engine_list.c ├── ol_lrc_engine_list.h ├── ol_lrc_fetch.c ├── ol_lrc_fetch.h ├── ol_lrc_fetch_module.c ├── ol_lrc_fetch_module.h ├── ol_lrc_fetch_ttplayer.c ├── ol_lrc_fetch_ttplayer.h ├── ol_lrc_fetch_ui.c ├── ol_lrc_fetch_ui.h ├── ol_lrc_fetch_utils.c ├── ol_lrc_fetch_utils.h ├── ol_lrc_fetch_xiami.c ├── ol_lrc_fetch_xiami.h ├── ol_lrc_parser.c ├── ol_lrc_parser.h ├── ol_lrclib.c ├── ol_lrclib.h ├── ol_lyric_manage.c ├── ol_lyric_manage.h ├── ol_main.c ├── ol_marshal.c ├── ol_marshal.h ├── ol_md5.c ├── ol_md5.h ├── ol_menu.c ├── ol_menu.h ├── ol_music_info.c ├── ol_music_info.h ├── ol_notify.c ├── ol_notify.h ├── ol_option.c ├── ol_option.h ├── ol_osd_module.c ├── ol_osd_module.h ├── ol_osd_render.c ├── ol_osd_render.h ├── ol_osd_toolbar.c ├── ol_osd_toolbar.h ├── ol_osd_window.c ├── ol_osd_window.h ├── ol_path_pattern.c ├── ol_path_pattern.h ├── ol_player.c ├── ol_player.h ├── ol_player_amarok1.c ├── ol_player_amarok1.h ├── ol_player_banshee.c ├── ol_player_banshee.h ├── ol_player_chooser.c ├── ol_player_chooser.h ├── ol_player_cmus.c ├── ol_player_cmus.h ├── ol_player_exaile02.c ├── ol_player_exaile02.h ├── ol_player_exaile03.c ├── ol_player_exaile03.h ├── ol_player_gmusicbrowser.c ├── ol_player_gmusicbrowser.h ├── ol_player_juk.c ├── ol_player_juk.h ├── ol_player_listen.c ├── ol_player_listen.h ├── ol_player_moc.c ├── ol_player_moc.h ├── ol_player_mpd.c ├── ol_player_mpd.h ├── ol_player_mpris.c ├── ol_player_mpris.h ├── ol_player_mpris2.c ├── ol_player_mpris2.h ├── ol_player_muine.c ├── ol_player_muine.h ├── ol_player_quodlibet.c ├── ol_player_quodlibet.h ├── ol_player_rhythmbox.c ├── ol_player_rhythmbox.h ├── ol_player_rhythmcat.c ├── ol_player_rhythmcat.h ├── ol_player_utils.c ├── ol_player_utils.h ├── ol_player_xmms2.c ├── ol_player_xmms2.h ├── ol_scroll_module.c ├── ol_scroll_module.h ├── ol_scroll_window.c ├── ol_scroll_window.h ├── ol_search_dialog.c ├── ol_search_dialog.h ├── ol_singleton.c ├── ol_singleton.h ├── ol_stock.c ├── ol_stock.h ├── ol_trayicon.c ├── ol_trayicon.h ├── ol_utils.c ├── ol_utils.h ├── ol_utils_cmdline.c ├── ol_utils_cmdline.h ├── ol_utils_dbus.c ├── ol_utils_dbus.h ├── ol_utils_dcop.c ├── ol_utils_dcop.h ├── ol_utils_network.c ├── ol_utils_network.h └── tests ├── Makefile.am ├── lrc_basic.lrc ├── lrc_bom.lrc ├── lrc_gbk.lrc ├── lrc_no_newline.lrc ├── lrc_tail.lrc ├── lyric2.lrc ├── lyric3.lrc ├── lyric4.lrc ├── lyric_with_offset.lrc ├── lyric_without_offset.lrc ├── lyrics1.lrc ├── mytest.lrc ├── ol_app_info_test.c ├── ol_color_test.c ├── ol_config_test.c ├── ol_fork_test.c ├── ol_gussian_blur_test.c ├── ol_lrc_fetch_check.c ├── ol_lrc_fetch_module_test.c ├── ol_lrc_fetch_test.c ├── ol_lrc_fetch_ui_test.c ├── ol_lrc_file_test.c ├── ol_lrc_parser_test.c ├── ol_lrc_test.c ├── ol_lrc_utility_test.c ├── ol_lrclib_test.c ├── ol_music_info_test.c ├── ol_osd_test.c ├── ol_osd_window_test.c ├── ol_path_test.c ├── ol_player_test.c ├── ol_test_util.h ├── ol_utils_cmdline_test.c ├── ol_utils_dbus_test.c └── ol_utils_test.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.gmo 3 | *.lo 4 | src/tests/*test 5 | Makefile 6 | Makefile.in 7 | *.a 8 | src/osdlyrics 9 | config.h 10 | config.h.in 11 | configure 12 | config.guess 13 | config.sub 14 | configure.scan 15 | po/POTFILES 16 | missing 17 | .deps 18 | aclocal.m4 19 | stamp-h1 20 | compile 21 | config.log 22 | depcomp 23 | po/stamp-it 24 | autom4te.cache 25 | config.status 26 | cscope.out 27 | *~ -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Tiger Soldier 2 | Sarlmol Apple 3 | Simply Zhao -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = lib src data po 2 | ACLOCAL_AMFLAGS = -I m4 3 | 4 | EXTRA_DIST = m4/ChangeLog 5 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | -*- mode: markdown -*- 2 | 3 | OSD Lyrics - Show lyrics with your favorite media player. 4 | 5 | Introduction 6 | ============ 7 | 8 | OSD Lyrics is a lyrics show compatible with various media players. It is not a plugin but a standalone program. OSD Lyrics shows lyrics on your desktop, in the style similar to KaraOK. It also provides another displaying style, in which lyrics scroll from bottom to top. OSD Lyrics can download lyrics from the network automatically. 9 | 10 | OSD Lyrics is released under GPL v3. See COPYING for more detail. 11 | 12 | Usage 13 | ===== 14 | 15 | To use OSD Lyrics, just launch your media player, then launch OSD Lyrics. OSD Lyrics will detect and connect to the media player. 16 | 17 | Contact Us 18 | ========== 19 | 20 | The home page of OSD Lyrics is http://code.google.com/p/osd-lyrics/ 21 | 22 | The source repository is on Github: http://github.com/tigersoldier/osd-lyrics 23 | 24 | If there is any feature request, suggestion, or bug, feel free to report them to http://code.google.com/p/osd-lyrics/issues/list 25 | 26 | The support mail list is osd-lyrics@googlegroups.com. You can also visit https://groups.google.com/group/osd-lyrics 27 | 28 | Contributing 29 | ============ 30 | 31 | - Help translate: https://translations.launchpad.net/osd-lyrics 32 | - Patch or bug report: http://code.google.com/p/osd-lyrics/issues/list 33 | - Any visual design is welcome :) 34 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | autoreconf --install 6 | ./configure $@ 7 | -------------------------------------------------------------------------------- /dailydeb.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACKAGE_VERSION=@PACKAGE_VERSION@ 4 | CURDATE=`date +%Y%m%d` 5 | ORGLANG=$LANG 6 | LANG=en_US 7 | 8 | mv debian/changelog debian/changelog.old 9 | 10 | echo "osdlyrics ($PACKAGE_VERSION.$CURDATE) unstable; urgency=low 11 | 12 | * Daily build 13 | 14 | -- TigerSoldier `date -R` 15 | " | cat - debian/changelog.old > debian/changelog 16 | 17 | #cat debian/changelog 18 | LANG=$ORGLANG 19 | dpkg-buildpackage 20 | 21 | mv debian/changelog.old debian/changelog 22 | -------------------------------------------------------------------------------- /data/Makefile.am: -------------------------------------------------------------------------------- 1 | trayicondir = ${datadir}/icons/hicolor/64x64/apps 2 | dist_trayicon_DATA = \ 3 | osdlyrics-trayicon.png 4 | guidir = @OL_GUIDIR@ 5 | dist_gui_DATA = \ 6 | dialogs.glade 7 | menudir = ${datadir}/applications 8 | dist_menu_DATA = osdlyrics.desktop 9 | icondir = ${datadir}/icons/hicolor/64x64/apps 10 | dist_icon_DATA = osdlyrics.png 11 | 12 | animdir = ${datadir}/icons/hicolor/16x16/animations 13 | dist_anim_DATA = osdlyrics-loading.png 14 | 15 | osd_icondir = ${datadir}/icons/hicolor/scalable/actions 16 | dist_osd_icon_DATA = \ 17 | osdlyrics-osd-play.svg \ 18 | osdlyrics-osd-pause.svg \ 19 | osdlyrics-osd-stop.svg \ 20 | osdlyrics-osd-next.svg \ 21 | osdlyrics-osd-prev.svg \ 22 | osdlyrics-scroll-close.svg 23 | 24 | bgdir = ${datadir}/icons/hicolor/scalable/apps 25 | dist_bg_DATA = osdlyrics-osd-bg.svg 26 | 27 | defaulticondir = @OL_ICONDIR@ 28 | dist_defaulticon_DATA = osdlyrics.png 29 | #svgdir = ${datadir}/icons/hicolor/scalable/apps 30 | #svg_DATA = osdlyrics.svg -------------------------------------------------------------------------------- /data/icons/osdlyric/128x128/osdlyric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/icons/osdlyric/128x128/osdlyric.png -------------------------------------------------------------------------------- /data/icons/osdlyric/22x22/osdlyric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/icons/osdlyric/22x22/osdlyric.png -------------------------------------------------------------------------------- /data/icons/osdlyric/32x32/osdlyric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/icons/osdlyric/32x32/osdlyric.png -------------------------------------------------------------------------------- /data/icons/osdlyric/48x48/osdlyric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/icons/osdlyric/48x48/osdlyric.png -------------------------------------------------------------------------------- /data/icons/osdlyric/64x64/osdlyric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/icons/osdlyric/64x64/osdlyric.png -------------------------------------------------------------------------------- /data/osdlyrics-loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/osdlyrics-loading.png -------------------------------------------------------------------------------- /data/osdlyrics-trayicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/osdlyrics-trayicon.png -------------------------------------------------------------------------------- /data/osdlyrics.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Exec=osdlyrics 3 | Version=1.0 4 | Name=OSD Lyrics 5 | GenericName=Lyrics Show 6 | GenericName[zh_CN]=歌词秀 7 | Comment=Download and show lyrics for your favorite media player 8 | Comment[zh_CN]=让你的音乐播放器支持下载和显示歌词 9 | Icon=osdlyrics 10 | StartupNotify=true 11 | Terminal=false 12 | Type=Application 13 | Categories=GTK;AudioVideo;Audio;Player;X-Ximian-Main;X-Novell-Main;X-Red-Hat-Base; 14 | MimeType= 15 | X-Ubuntu-Gettext-Domain=osdlyrics 16 | -------------------------------------------------------------------------------- /data/osdlyrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/data/osdlyrics.png -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = chardetect -------------------------------------------------------------------------------- /lib/chardetect/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libchardetect.a 2 | libchardetect_a_CXXFLAGS = \ 3 | -c \ 4 | -O2 \ 5 | -fno-rtti -fno-exceptions \ 6 | -fvisibility=hidden -fvisibility-inlines-hidden \ 7 | -nostdinc++ \ 8 | -D_REENTRANT \ 9 | -I$(srcdir)/src \ 10 | -I$(srcdir)/include \ 11 | -I$(srcdir)/src/tables 12 | libchardetect_a_SOURCES = \ 13 | src/CharDistribution.cpp \ 14 | src/JpCntx.cpp \ 15 | src/LangBulgarianModel.cpp \ 16 | src/LangCyrillicModel.cpp \ 17 | src/LangGreekModel.cpp \ 18 | src/LangHebrewModel.cpp \ 19 | src/LangHungarianModel.cpp \ 20 | src/LangThaiModel.cpp \ 21 | src/nsBig5Prober.cpp \ 22 | src/nsCharSetProber.cpp \ 23 | src/nsEscCharsetProber.cpp \ 24 | src/nsEscSM.cpp \ 25 | src/nsEUCJPProber.cpp \ 26 | src/nsEUCKRProber.cpp \ 27 | src/nsEUCTWProber.cpp \ 28 | src/nsGB2312Prober.cpp \ 29 | src/nsHebrewProber.cpp \ 30 | src/nsLatin1Prober.cpp \ 31 | src/nsMBCSGroupProber.cpp \ 32 | src/nsMBCSSM.cpp \ 33 | src/nsSBCharSetProber.cpp \ 34 | src/nsSBCSGroupProber.cpp \ 35 | src/nsSJISProber.cpp \ 36 | src/nsUniversalDetector.cpp \ 37 | src/nsUTF8Prober.cpp \ 38 | src/entry/impl.cpp 39 | 40 | noinst_HEADERS = \ 41 | include/chardetect.h \ 42 | src/CharDistribution.h \ 43 | src/JpCntx.h \ 44 | src/nsBig5Prober.h \ 45 | src/nsCharSetProber.h \ 46 | src/nsCodingStateMachine.h \ 47 | src/nscore.h \ 48 | src/nsEscCharsetProber.h \ 49 | src/nsEUCJPProber.h \ 50 | src/nsEUCKRProber.h \ 51 | src/nsEUCTWProber.h \ 52 | src/nsGB2312Prober.h \ 53 | src/nsHebrewProber.h \ 54 | src/nsLatin1Prober.h \ 55 | src/nsMBCSGroupProber.h \ 56 | src/nsPkgInt.h \ 57 | src/nsSBCharSetProber.h \ 58 | src/nsSBCSGroupProber.h \ 59 | src/nsSJISProber.h \ 60 | src/nsUniversalDetector.h \ 61 | src/nsUTF8Prober.h \ 62 | src/prmem.h \ 63 | src/tables/Big5Freq.tab \ 64 | src/tables/EUCKRFreq.tab \ 65 | src/tables/EUCTWFreq.tab \ 66 | src/tables/GB2312Freq.tab \ 67 | src/tables/JISFreq.tab 68 | -------------------------------------------------------------------------------- /lib/chardetect/README: -------------------------------------------------------------------------------- 1 | Universal Character Set Detector C Library 2 | 3 | 4 | 1. What is it? 5 | 6 | A port to C of "universalchardet", that is the encoding detector 7 | library of Mozilla. 8 | 9 | The original code of universalchardet is available at 10 | http://lxr.mozilla.org/seamonkey/source/extensions/universalchardet/ 11 | 12 | 13 | 2. API 14 | 15 | See universalchardet.h. 16 | 17 | 18 | 3. License 19 | 20 | The library is subject to the Mozilla Public License Version 1.1. 21 | Alternatively, the library may be used under the terms of either 22 | the GNU General Public License Version 2 or later, or the GNU 23 | Lesser General Public License 2.1 or later. 24 | 25 | -------------------------------------------------------------------------------- /lib/chardetect/src/Makefile: -------------------------------------------------------------------------------- 1 | CXXFLAGS = \ 2 | -c -I./tables \ 3 | -Os -Wall \ 4 | -fno-rtti -fno-exceptions \ 5 | -fvisibility=hidden -fvisibility-inlines-hidden \ 6 | -nostdinc++ \ 7 | -D_REENTRANT 8 | 9 | LDFLAGS = 10 | 11 | SRCS = \ 12 | CharDistribution.cpp \ 13 | JpCntx.cpp \ 14 | LangBulgarianModel.cpp \ 15 | LangCyrillicModel.cpp \ 16 | LangGreekModel.cpp \ 17 | LangHebrewModel.cpp \ 18 | LangHungarianModel.cpp \ 19 | LangThaiModel.cpp \ 20 | nsBig5Prober.cpp \ 21 | nsCharSetProber.cpp \ 22 | nsEUCJPProber.cpp \ 23 | nsEUCKRProber.cpp \ 24 | nsEUCTWProber.cpp \ 25 | nsEscCharsetProber.cpp \ 26 | nsEscSM.cpp \ 27 | nsGB2312Prober.cpp \ 28 | nsHebrewProber.cpp \ 29 | nsLatin1Prober.cpp \ 30 | nsMBCSGroupProber.cpp \ 31 | nsMBCSSM.cpp \ 32 | nsSBCSGroupProber.cpp \ 33 | nsSBCharSetProber.cpp \ 34 | nsSJISProber.cpp \ 35 | nsUTF8Prober.cpp \ 36 | nsUniversalDetector.cpp 37 | 38 | OBJS=$(SRCS:%.cpp=%.o) 39 | 40 | all: $(OBJS) 41 | 42 | $(OBJS): %.o: %.cpp 43 | libtool --mode=compile $(CXX) $(CXXFLAGS) $< 44 | 45 | clean: 46 | rm -f *.o 47 | rm -f *.lo 48 | rm -rf .libs 49 | -------------------------------------------------------------------------------- /lib/chardetect/src/entry/export-symbol.list: -------------------------------------------------------------------------------- 1 | chardet_create 2 | chardet_destroy 3 | chardet_handle_data 4 | chardet_data_end 5 | chardet_reset 6 | chardet_get_charset 7 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsBig5Prober.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsBig5Prober_h__ 39 | #define nsBig5Prober_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | #include "CharDistribution.h" 44 | 45 | class nsBig5Prober: public nsCharSetProber { 46 | public: 47 | nsBig5Prober(void){mCodingSM = new nsCodingStateMachine(&Big5SMModel); 48 | Reset();}; 49 | virtual ~nsBig5Prober(void){delete mCodingSM;}; 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return "Big5";}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | protected: 58 | void GetDistribution(PRUint32 aCharLen, const char* aStr); 59 | 60 | nsCodingStateMachine* mCodingSM; 61 | nsProbingState mState; 62 | 63 | //Big5ContextAnalysis mContextAnalyser; 64 | Big5DistributionAnalysis mDistributionAnalyser; 65 | char mLastChar[2]; 66 | 67 | }; 68 | 69 | 70 | #endif /* nsBig5Prober_h__ */ 71 | 72 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsEUCJPProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | // for S-JIS encoding, obeserve characteristic: 39 | // 1, kana character (or hankaku?) often have hight frequency of appereance 40 | // 2, kana character often exist in group 41 | // 3, certain combination of kana is never used in japanese language 42 | 43 | #ifndef nsEUCJPProber_h__ 44 | #define nsEUCJPProber_h__ 45 | 46 | #include "nsCharSetProber.h" 47 | #include "nsCodingStateMachine.h" 48 | #include "JpCntx.h" 49 | #include "CharDistribution.h" 50 | 51 | class nsEUCJPProber: public nsCharSetProber { 52 | public: 53 | nsEUCJPProber(void){mCodingSM = new nsCodingStateMachine(&EUCJPSMModel); 54 | Reset();}; 55 | virtual ~nsEUCJPProber(void){delete mCodingSM;}; 56 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 57 | const char* GetCharSetName() {return "EUC-JP";}; 58 | nsProbingState GetState(void) {return mState;}; 59 | void Reset(void); 60 | float GetConfidence(void); 61 | void SetOpion() {}; 62 | 63 | protected: 64 | nsCodingStateMachine* mCodingSM; 65 | nsProbingState mState; 66 | 67 | EUCJPContextAnalysis mContextAnalyser; 68 | EUCJPDistributionAnalysis mDistributionAnalyser; 69 | 70 | char mLastChar[2]; 71 | }; 72 | 73 | 74 | #endif /* nsEUCJPProber_h__ */ 75 | 76 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsEUCKRProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsEUCKRProber_h__ 39 | #define nsEUCKRProber_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | #include "CharDistribution.h" 44 | 45 | class nsEUCKRProber: public nsCharSetProber { 46 | public: 47 | nsEUCKRProber(void){mCodingSM = new nsCodingStateMachine(&EUCKRSMModel); 48 | Reset();}; 49 | virtual ~nsEUCKRProber(void){delete mCodingSM;}; 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return "EUC-KR";}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | protected: 58 | void GetDistribution(PRUint32 aCharLen, const char* aStr); 59 | 60 | nsCodingStateMachine* mCodingSM; 61 | nsProbingState mState; 62 | 63 | //EUCKRContextAnalysis mContextAnalyser; 64 | EUCKRDistributionAnalysis mDistributionAnalyser; 65 | char mLastChar[2]; 66 | 67 | }; 68 | 69 | 70 | #endif /* nsEUCKRProber_h__ */ 71 | 72 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsEUCTWProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsEUCTWProber_h__ 39 | #define nsEUCTWProber_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | #include "CharDistribution.h" 44 | 45 | class nsEUCTWProber: public nsCharSetProber { 46 | public: 47 | nsEUCTWProber(void){mCodingSM = new nsCodingStateMachine(&EUCTWSMModel); 48 | Reset();}; 49 | virtual ~nsEUCTWProber(void){delete mCodingSM;}; 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return "x-euc-tw";}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | protected: 58 | void GetDistribution(PRUint32 aCharLen, const char* aStr); 59 | 60 | nsCodingStateMachine* mCodingSM; 61 | nsProbingState mState; 62 | 63 | //EUCTWContextAnalysis mContextAnalyser; 64 | EUCTWDistributionAnalysis mDistributionAnalyser; 65 | char mLastChar[2]; 66 | 67 | }; 68 | 69 | 70 | #endif /* nsEUCTWProber_h__ */ 71 | 72 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsEscCharsetProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsEscCharSetProber_h__ 39 | #define nsEscCharSetProber_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | 44 | #define NUM_OF_ESC_CHARSETS 4 45 | 46 | class nsEscCharSetProber: public nsCharSetProber { 47 | public: 48 | nsEscCharSetProber(void); 49 | virtual ~nsEscCharSetProber(void); 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return mDetectedCharset;}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void){return (float)0.99;}; 55 | void SetOpion() {}; 56 | 57 | protected: 58 | void GetDistribution(PRUint32 aCharLen, const char* aStr); 59 | 60 | nsCodingStateMachine* mCodingSM[NUM_OF_ESC_CHARSETS] ; 61 | PRUint32 mActiveSM; 62 | nsProbingState mState; 63 | const char * mDetectedCharset; 64 | }; 65 | 66 | #endif /* nsEscCharSetProber_h__ */ 67 | 68 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsGB2312Prober.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsGB2312Prober_h__ 39 | #define nsGB2312Prober_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | #include "CharDistribution.h" 44 | 45 | // We use gb18030 to replace gb2312, because 18030 is a superset. 46 | 47 | class nsGB18030Prober: public nsCharSetProber { 48 | public: 49 | nsGB18030Prober(void){mCodingSM = new nsCodingStateMachine(&GB18030SMModel); 50 | Reset();}; 51 | virtual ~nsGB18030Prober(void){delete mCodingSM;}; 52 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 53 | const char* GetCharSetName() {return "gb18030";}; 54 | nsProbingState GetState(void) {return mState;}; 55 | void Reset(void); 56 | float GetConfidence(void); 57 | void SetOpion() {}; 58 | 59 | protected: 60 | void GetDistribution(PRUint32 aCharLen, const char* aStr); 61 | 62 | nsCodingStateMachine* mCodingSM; 63 | nsProbingState mState; 64 | 65 | //GB2312ContextAnalysis mContextAnalyser; 66 | GB2312DistributionAnalysis mDistributionAnalyser; 67 | char mLastChar[2]; 68 | 69 | }; 70 | 71 | 72 | #endif /* nsGB2312Prober_h__ */ 73 | 74 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsLatin1Prober.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Mozilla Universal charset detector code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 2001 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Shy Shalom 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | #ifndef nsLatin1Prober_h__ 40 | #define nsLatin1Prober_h__ 41 | 42 | #include "nsCharSetProber.h" 43 | 44 | #define FREQ_CAT_NUM 4 45 | 46 | class nsLatin1Prober: public nsCharSetProber { 47 | public: 48 | nsLatin1Prober(void){Reset();}; 49 | virtual ~nsLatin1Prober(void){}; 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return "windows-1252";}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | #ifdef DEBUG_chardet 58 | virtual void DumpStatus(); 59 | #endif 60 | 61 | protected: 62 | 63 | nsProbingState mState; 64 | char mLastCharClass; 65 | PRUint32 mFreqCounter[FREQ_CAT_NUM]; 66 | }; 67 | 68 | 69 | #endif /* nsLatin1Prober_h__ */ 70 | 71 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsMBCSGroupProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsMBCSGroupProber_h__ 39 | #define nsMBCSGroupProber_h__ 40 | 41 | #include "nsSJISProber.h" 42 | #include "nsUTF8Prober.h" 43 | #include "nsEUCJPProber.h" 44 | #include "nsGB2312Prober.h" 45 | #include "nsEUCKRProber.h" 46 | #include "nsBig5Prober.h" 47 | #include "nsEUCTWProber.h" 48 | 49 | #define NUM_OF_PROBERS 7 50 | 51 | class nsMBCSGroupProber: public nsCharSetProber { 52 | public: 53 | nsMBCSGroupProber(); 54 | virtual ~nsMBCSGroupProber(); 55 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 56 | const char* GetCharSetName(); 57 | nsProbingState GetState(void) {return mState;}; 58 | void Reset(void); 59 | float GetConfidence(void); 60 | void SetOpion() {}; 61 | 62 | #ifdef DEBUG_chardet 63 | void DumpStatus(); 64 | #endif 65 | 66 | protected: 67 | nsProbingState mState; 68 | nsCharSetProber* mProbers[NUM_OF_PROBERS]; 69 | PRBool mIsActive[NUM_OF_PROBERS]; 70 | PRInt32 mBestGuess; 71 | PRUint32 mActiveNum; 72 | }; 73 | 74 | #endif /* nsMBCSGroupProber_h__ */ 75 | 76 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsSBCSGroupProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Mozilla Universal charset detector code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 2001 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * Shy Shalom 24 | * 25 | * Alternatively, the contents of this file may be used under the terms of 26 | * either the GNU General Public License Version 2 or later (the "GPL"), or 27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 | * in which case the provisions of the GPL or the LGPL are applicable instead 29 | * of those above. If you wish to allow use of your version of this file only 30 | * under the terms of either the GPL or the LGPL, and not to allow others to 31 | * use your version of this file under the terms of the MPL, indicate your 32 | * decision by deleting the provisions above and replace them with the notice 33 | * and other provisions required by the GPL or the LGPL. If you do not delete 34 | * the provisions above, a recipient may use your version of this file under 35 | * the terms of any one of the MPL, the GPL or the LGPL. 36 | * 37 | * ***** END LICENSE BLOCK ***** */ 38 | 39 | #ifndef nsSBCSGroupProber_h__ 40 | #define nsSBCSGroupProber_h__ 41 | 42 | 43 | #define NUM_OF_SBCS_PROBERS 13 44 | 45 | class nsCharSetProber; 46 | class nsSBCSGroupProber: public nsCharSetProber { 47 | public: 48 | nsSBCSGroupProber(); 49 | virtual ~nsSBCSGroupProber(); 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName(); 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | #ifdef DEBUG_chardet 58 | void DumpStatus(); 59 | #endif 60 | 61 | protected: 62 | nsProbingState mState; 63 | nsCharSetProber* mProbers[NUM_OF_SBCS_PROBERS]; 64 | PRBool mIsActive[NUM_OF_SBCS_PROBERS]; 65 | PRInt32 mBestGuess; 66 | PRUint32 mActiveNum; 67 | }; 68 | 69 | #endif /* nsSBCSGroupProber_h__ */ 70 | 71 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsSJISProber.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | // for S-JIS encoding, obeserve characteristic: 39 | // 1, kana character (or hankaku?) often have hight frequency of appereance 40 | // 2, kana character often exist in group 41 | // 3, certain combination of kana is never used in japanese language 42 | 43 | #ifndef nsSJISProber_h__ 44 | #define nsSJISProber_h__ 45 | 46 | #include "nsCharSetProber.h" 47 | #include "nsCodingStateMachine.h" 48 | #include "JpCntx.h" 49 | #include "CharDistribution.h" 50 | 51 | 52 | class nsSJISProber: public nsCharSetProber { 53 | public: 54 | nsSJISProber(void){mCodingSM = new nsCodingStateMachine(&SJISSMModel); 55 | Reset();}; 56 | virtual ~nsSJISProber(void){delete mCodingSM;}; 57 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 58 | const char* GetCharSetName() {return "Shift_JIS";}; 59 | nsProbingState GetState(void) {return mState;}; 60 | void Reset(void); 61 | float GetConfidence(void); 62 | void SetOpion() {}; 63 | 64 | protected: 65 | nsCodingStateMachine* mCodingSM; 66 | nsProbingState mState; 67 | 68 | SJISContextAnalysis mContextAnalyser; 69 | SJISDistributionAnalysis mDistributionAnalyser; 70 | 71 | char mLastChar[2]; 72 | 73 | }; 74 | 75 | 76 | #endif /* nsSJISProber_h__ */ 77 | 78 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsUTF8Prober.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #pragma GCC visibility push(hidden) 39 | 40 | #include "nsUTF8Prober.h" 41 | 42 | void nsUTF8Prober::Reset(void) 43 | { 44 | mCodingSM->Reset(); 45 | mNumOfMBChar = 0; 46 | mState = eDetecting; 47 | } 48 | 49 | nsProbingState nsUTF8Prober::HandleData(const char* aBuf, PRUint32 aLen) 50 | { 51 | nsSMState codingState; 52 | 53 | for (PRUint32 i = 0; i < aLen; i++) 54 | { 55 | codingState = mCodingSM->NextState(aBuf[i]); 56 | if (codingState == eError) 57 | { 58 | mState = eNotMe; 59 | break; 60 | } 61 | if (codingState == eItsMe) 62 | { 63 | mState = eFoundIt; 64 | break; 65 | } 66 | if (codingState == eStart) 67 | { 68 | if (mCodingSM->GetCurrentCharLen() >= 2) 69 | mNumOfMBChar++; 70 | } 71 | } 72 | 73 | if (mState == eDetecting) 74 | if (GetConfidence() > SHORTCUT_THRESHOLD) 75 | mState = eFoundIt; 76 | return mState; 77 | } 78 | 79 | #define ONE_CHAR_PROB (float)0.50 80 | 81 | float nsUTF8Prober::GetConfidence(void) 82 | { 83 | float unlike = (float)0.99; 84 | 85 | if (mNumOfMBChar < 6) 86 | { 87 | for (PRUint32 i = 0; i < mNumOfMBChar; i++) 88 | unlike *= ONE_CHAR_PROB; 89 | return (float)1.0 - unlike; 90 | } 91 | else 92 | return (float)0.99; 93 | } 94 | 95 | #pragma GCC visibility pop 96 | 97 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsUTF8Prober.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is mozilla.org code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsUTF8Prober_h__ 39 | #define nsUTF8Prober_h__ 40 | 41 | #include "nsCharSetProber.h" 42 | #include "nsCodingStateMachine.h" 43 | 44 | class nsUTF8Prober: public nsCharSetProber { 45 | public: 46 | nsUTF8Prober(){mNumOfMBChar = 0; 47 | mCodingSM = new nsCodingStateMachine(&UTF8SMModel); 48 | Reset(); }; 49 | virtual ~nsUTF8Prober(){delete mCodingSM;}; 50 | nsProbingState HandleData(const char* aBuf, PRUint32 aLen); 51 | const char* GetCharSetName() {return "UTF-8";}; 52 | nsProbingState GetState(void) {return mState;}; 53 | void Reset(void); 54 | float GetConfidence(void); 55 | void SetOpion() {}; 56 | 57 | protected: 58 | nsCodingStateMachine* mCodingSM; 59 | nsProbingState mState; 60 | PRUint32 mNumOfMBChar; 61 | }; 62 | 63 | #endif /* nsUTF8Prober_h__ */ 64 | 65 | -------------------------------------------------------------------------------- /lib/chardetect/src/nsUniversalDetector.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 | /* ***** BEGIN LICENSE BLOCK ***** 3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 | * 5 | * The contents of this file are subject to the Mozilla Public License Version 6 | * 1.1 (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * http://www.mozilla.org/MPL/ 9 | * 10 | * Software distributed under the License is distributed on an "AS IS" basis, 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 | * for the specific language governing rights and limitations under the 13 | * License. 14 | * 15 | * The Original Code is Mozilla Communicator client code. 16 | * 17 | * The Initial Developer of the Original Code is 18 | * Netscape Communications Corporation. 19 | * Portions created by the Initial Developer are Copyright (C) 1998 20 | * the Initial Developer. All Rights Reserved. 21 | * 22 | * Contributor(s): 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef nsUniversalDetector_h__ 39 | #define nsUniversalDetector_h__ 40 | 41 | class nsCharSetProber; 42 | 43 | #define NUM_OF_CHARSET_PROBERS 3 44 | 45 | typedef enum { 46 | ePureAscii = 0, 47 | eEscAscii = 1, 48 | eHighbyte = 2 49 | } nsInputState; 50 | 51 | class nsUniversalDetector { 52 | public: 53 | nsUniversalDetector(); 54 | virtual ~nsUniversalDetector(); 55 | virtual nsresult HandleData(const char* aBuf, PRUint32 aLen); 56 | virtual void DataEnd(void); 57 | 58 | protected: 59 | virtual void Report(const char* aCharset) = 0; 60 | virtual void Reset(); 61 | nsInputState mInputState; 62 | PRBool mDone; 63 | PRBool mInTag; 64 | PRBool mStart; 65 | PRBool mGotData; 66 | char mLastChar; 67 | const char * mDetectedCharset; 68 | PRInt32 mBestGuess; 69 | 70 | nsCharSetProber *mCharSetProbers[NUM_OF_CHARSET_PROBERS]; 71 | nsCharSetProber *mEscCharSetProber; 72 | }; 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /lib/chardetect/src/nscore.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Mozilla Universal charset detector code. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Netscape Communications Corporation. 18 | * Portions created by the Initial Developer are Copyright (C) 2001 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Kohei TAKETA 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | #ifndef nsDummyCore_h__ 38 | #define nsDummyCore_h__ 39 | 40 | typedef bool PRBool; 41 | typedef int PRInt32; 42 | typedef unsigned int PRUint32; 43 | typedef short PRInt16; 44 | typedef unsigned short PRUint16; 45 | 46 | #define PR_FALSE false 47 | #define PR_TRUE true 48 | #define nsnull 0 49 | 50 | 51 | enum nsresult 52 | { 53 | NS_OK, 54 | NS_ERROR_OUT_OF_MEMORY 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/chardetect/src/prmem.h: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Mozilla Universal charset detector code. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Netscape Communications Corporation. 18 | * Portions created by the Initial Developer are Copyright (C) 2001 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Kohei TAKETA 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | #ifndef nsDummyPrmem_h__ 38 | #define nsDummyPrmem_h__ 39 | 40 | #include 41 | 42 | inline void* PR_Malloc(size_t len) 43 | { 44 | return malloc(len); 45 | } 46 | 47 | #define PR_FREEIF(p) do { if (p) free(p); } while(0) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lib/chardetect/test/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=test-chardetect 2 | 3 | all: $(TARGET) 4 | 5 | $(TARGET): test-chardetect.c 6 | $(CC) \ 7 | -O2 \ 8 | -o $(TARGET) \ 9 | test-chardetect.c \ 10 | -I../include \ 11 | -ldl 12 | 13 | clean: 14 | rm -f $(TARGET) 15 | -------------------------------------------------------------------------------- /lib/chardetect/test/test-chardetect.c: -------------------------------------------------------------------------------- 1 | #include "chardetect.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define LIB_PREFIX "../" 8 | #define LIB_NAME "chardetect.so" 9 | #define LIB_PATH LIB_PREFIX LIB_NAME 10 | 11 | static void (*chardet_func)(chardet_t *); 12 | static void (*chardet_func2)(chardet_t); 13 | static int (*chardet_func_with_param)(chardet_t, char *, int); 14 | static void *handle; 15 | static const char *error; 16 | 17 | static void perform_charset_detection(FILE* fp) 18 | { 19 | char buf[4096]; 20 | char encoding[CHARDET_MAX_ENCODING_NAME]; 21 | size_t len; 22 | int res = 0; 23 | chardet_t det = NULL; 24 | 25 | handle = dlopen(LIB_PATH, RTLD_NOW); 26 | if (! handle) { 27 | fputs(dlerror(), stderr); 28 | return; 29 | } 30 | 31 | chardet_func = dlsym(handle, "chardet_create"); 32 | if ((error = dlerror()) != NULL) { 33 | fputs(error, stderr); 34 | return; 35 | } 36 | (*chardet_func)(&det); 37 | 38 | chardet_func_with_param = dlsym(handle, "chardet_handle_data"); 39 | if ((error = dlerror()) != NULL) { 40 | fputs(error, stderr); 41 | return; 42 | } 43 | do { 44 | len = fread(buf, 1, sizeof(buf), fp); 45 | res = (*chardet_func_with_param)(det, buf, len); 46 | } while ((res == CHARDET_RESULT_OK) && (feof(fp) == 0)); 47 | 48 | chardet_func2 = dlsym(handle, "chardet_data_end"); 49 | if ((error = dlerror()) != NULL) { 50 | fputs(error, stderr); 51 | return; 52 | } 53 | (*chardet_func2)(det); 54 | 55 | chardet_func_with_param = dlsym(handle, "chardet_get_charset"); 56 | if ((error = dlerror()) != NULL) { 57 | fputs(error, stderr); 58 | return; 59 | } 60 | (*chardet_func_with_param)(det, encoding, CHARDET_MAX_ENCODING_NAME); 61 | printf("Charset = %s\n", encoding); 62 | 63 | chardet_func2 = dlsym(handle, "chardet_destroy"); 64 | if ((error = dlerror()) != NULL) { 65 | fputs(error, stderr); 66 | return; 67 | } 68 | (*chardet_func2)(det); 69 | 70 | dlclose(handle); 71 | } 72 | 73 | int main(int argc, char* argv[]) 74 | { 75 | FILE* fp = NULL; 76 | 77 | if (argc > 1) { 78 | fp = fopen(argv[1], "rb"); 79 | if (fp) { 80 | printf("File %s ...\n", argv[1]); 81 | perform_charset_detection(fp); 82 | fclose(fp); 83 | } 84 | else { 85 | printf("Can't open %s\n", argv[1]); 86 | return 1; 87 | } 88 | } 89 | else { 90 | printf("Usage: %s filename\n", argv[0]); 91 | return 1; 92 | } 93 | 94 | return 0; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /m4/ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-07-08 gettextize 2 | 3 | * gettext.m4: New file, from gettext-0.17. 4 | * iconv.m4: New file, from gettext-0.17. 5 | * lib-ld.m4: New file, from gettext-0.17. 6 | * lib-link.m4: New file, from gettext-0.17. 7 | * lib-prefix.m4: New file, from gettext-0.17. 8 | * nls.m4: New file, from gettext-0.17. 9 | * po.m4: New file, from gettext-0.17. 10 | * progtest.m4: New file, from gettext-0.17. 11 | 12 | -------------------------------------------------------------------------------- /m4/nls.m4: -------------------------------------------------------------------------------- 1 | # nls.m4 serial 3 (gettext-0.15) 2 | dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1995-2000. 18 | dnl Bruno Haible , 2000-2003. 19 | 20 | AC_PREREQ(2.50) 21 | 22 | AC_DEFUN([AM_NLS], 23 | [ 24 | AC_MSG_CHECKING([whether NLS is requested]) 25 | dnl Default is enabled NLS 26 | AC_ARG_ENABLE(nls, 27 | [ --disable-nls do not use Native Language Support], 28 | USE_NLS=$enableval, USE_NLS=yes) 29 | AC_MSG_RESULT($USE_NLS) 30 | AC_SUBST(USE_NLS) 31 | ]) 32 | -------------------------------------------------------------------------------- /m4/progtest.m4: -------------------------------------------------------------------------------- 1 | # progtest.m4 serial 4 (gettext-0.14.2) 2 | dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1996. 18 | 19 | AC_PREREQ(2.50) 20 | 21 | # Search path for a program which passes the given test. 22 | 23 | dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, 24 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) 25 | AC_DEFUN([AM_PATH_PROG_WITH_TEST], 26 | [ 27 | # Prepare PATH_SEPARATOR. 28 | # The user is always right. 29 | if test "${PATH_SEPARATOR+set}" != set; then 30 | echo "#! /bin/sh" >conf$$.sh 31 | echo "exit 0" >>conf$$.sh 32 | chmod +x conf$$.sh 33 | if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then 34 | PATH_SEPARATOR=';' 35 | else 36 | PATH_SEPARATOR=: 37 | fi 38 | rm -f conf$$.sh 39 | fi 40 | 41 | # Find out how to test for executable files. Don't use a zero-byte file, 42 | # as systems may use methods other than mode bits to determine executability. 43 | cat >conf$$.file <<_ASEOF 44 | #! /bin/sh 45 | exit 0 46 | _ASEOF 47 | chmod +x conf$$.file 48 | if test -x conf$$.file >/dev/null 2>&1; then 49 | ac_executable_p="test -x" 50 | else 51 | ac_executable_p="test -f" 52 | fi 53 | rm -f conf$$.file 54 | 55 | # Extract the first word of "$2", so it can be a program name with args. 56 | set dummy $2; ac_word=[$]2 57 | AC_MSG_CHECKING([for $ac_word]) 58 | AC_CACHE_VAL(ac_cv_path_$1, 59 | [case "[$]$1" in 60 | [[\\/]]* | ?:[[\\/]]*) 61 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. 62 | ;; 63 | *) 64 | ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR 65 | for ac_dir in ifelse([$5], , $PATH, [$5]); do 66 | IFS="$ac_save_IFS" 67 | test -z "$ac_dir" && ac_dir=. 68 | for ac_exec_ext in '' $ac_executable_extensions; do 69 | if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then 70 | echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD 71 | if [$3]; then 72 | ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" 73 | break 2 74 | fi 75 | fi 76 | done 77 | done 78 | IFS="$ac_save_IFS" 79 | dnl If no 4th arg is given, leave the cache variable unset, 80 | dnl so AC_PATH_PROGS will keep looking. 81 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" 82 | ])dnl 83 | ;; 84 | esac])dnl 85 | $1="$ac_cv_path_$1" 86 | if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then 87 | AC_MSG_RESULT([$]$1) 88 | else 89 | AC_MSG_RESULT(no) 90 | fi 91 | AC_SUBST($1)dnl 92 | ]) 93 | -------------------------------------------------------------------------------- /packsrc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /tmp 3 | rm -rf osdlyrics 4 | svn export --force http://osd-lyrics.googlecode.com/svn/trunk/ osdlyrics 5 | cd osdlyrics 6 | version=`grep AC_INIT configure.ac | cut -d , -f 2 | cut -d [ -f 2 | cut -d ] -f 1` 7 | aclocal 8 | autoconf 9 | automake --add-missing --copy 10 | make 11 | make distclean 12 | cd .. 13 | mdirname=osdlyrics-$version 14 | [ -e $dirname ] && rm -rf $mdirname 15 | mv osdlyrics $mdirname 16 | fullversion=$version 17 | tarname=osdlyrics-$fullversion.tar.gz 18 | [ -e $tarname ] && rm -rf $tarname 19 | tar zcvf $tarname $mdirname 20 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2009-07-08 gettextize 2 | 3 | * Makefile.in.in: New file, from gettext-0.17. 4 | * Rules-quot: New file, from gettext-0.17. 5 | * boldquot.sed: New file, from gettext-0.17. 6 | * en@boldquot.header: New file, from gettext-0.17. 7 | * en@quot.header: New file, from gettext-0.17. 8 | * insert-header.sin: New file, from gettext-0.17. 9 | * quot.sed: New file, from gettext-0.17. 10 | * remove-potcdate.sin: New file, from gettext-0.17. 11 | * POTFILES.in: New file. 12 | 13 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | de es fr it ms pt_BR ro ru tr uk zh_CN zh_HK zh_TW 2 | -------------------------------------------------------------------------------- /po/Makefile.in.in: -------------------------------------------------------------------------------- 1 | /usr/share/intltool/Makefile.in.in -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Free Software Foundation, Inc. 22 | 23 | # This is the email address or URL to which the translators shall report 24 | # bugs in the untranslated strings: 25 | # - Strings which are not entire sentences, see the maintainer guidelines 26 | # in the GNU gettext documentation, section 'Preparing Strings'. 27 | # - Strings which use unclear terms or require additional context to be 28 | # understood. 29 | # - Strings which make invalid assumptions about notation of date, time or 30 | # money. 31 | # - Pluralisation problems. 32 | # - Incorrect English spelling. 33 | # - Incorrect formatting. 34 | # It can be your email address, or a mailing list address where translators 35 | # can write to without being subscribed, or the URL of a web page through 36 | # which the translators can contact you. 37 | MSGID_BUGS_ADDRESS = 38 | 39 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 40 | # message catalogs shall be used. It is usually empty. 41 | EXTRA_LOCALE_CATEGORIES = 42 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files which contain translatable strings. 2 | src/ol_menu.c 3 | src/ol_main.c 4 | src/ol_trayicon.c 5 | src/ol_option.c 6 | src/ol_lrc_fetch_ttplayer.c 7 | src/ol_lrc_fetch_xiami.c 8 | src/ol_lrc_candidate_list.c 9 | src/ol_search_dialog.c 10 | src/ol_notify.c 11 | src/ol_player_chooser.c 12 | src/ol_app_info.c 13 | src/ol_scroll_window.c 14 | data/dialogs.glade 15 | -------------------------------------------------------------------------------- /po/Rules-quot: -------------------------------------------------------------------------------- 1 | # Special Makefile rules for English message catalogs with quotation marks. 2 | 3 | DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot 4 | 5 | .SUFFIXES: .insert-header .po-update-en 6 | 7 | en@quot.po-create: 8 | $(MAKE) en@quot.po-update 9 | en@boldquot.po-create: 10 | $(MAKE) en@boldquot.po-update 11 | 12 | en@quot.po-update: en@quot.po-update-en 13 | en@boldquot.po-update: en@boldquot.po-update-en 14 | 15 | .insert-header.po-update-en: 16 | @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ 17 | if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ 18 | tmpdir=`pwd`; \ 19 | echo "$$lang:"; \ 20 | ll=`echo $$lang | sed -e 's/@.*//'`; \ 21 | LC_ALL=C; export LC_ALL; \ 22 | cd $(srcdir); \ 23 | if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ 24 | if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 25 | rm -f $$tmpdir/$$lang.new.po; \ 26 | else \ 27 | if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 28 | :; \ 29 | else \ 30 | echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 31 | exit 1; \ 32 | fi; \ 33 | fi; \ 34 | else \ 35 | echo "creation of $$lang.po failed!" 1>&2; \ 36 | rm -f $$tmpdir/$$lang.new.po; \ 37 | fi 38 | 39 | en@quot.insert-header: insert-header.sin 40 | sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header 41 | 42 | en@boldquot.insert-header: insert-header.sin 43 | sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header 44 | 45 | mostlyclean: mostlyclean-quot 46 | mostlyclean-quot: 47 | rm -f *.insert-header 48 | -------------------------------------------------------------------------------- /po/boldquot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | s/“/“/g 8 | s/”/”/g 9 | s/‘/‘/g 10 | s/’/’/g 11 | -------------------------------------------------------------------------------- /po/en@boldquot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | # This catalog furthermore displays the text between the quotation marks in 24 | # bold face, assuming the VT100/XTerm escape sequences. 25 | # 26 | -------------------------------------------------------------------------------- /po/en@quot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | -------------------------------------------------------------------------------- /po/insert-header.sin: -------------------------------------------------------------------------------- 1 | # Sed script that inserts the file called HEADER before the header entry. 2 | # 3 | # At each occurrence of a line starting with "msgid ", we execute the following 4 | # commands. At the first occurrence, insert the file. At the following 5 | # occurrences, do nothing. The distinction between the first and the following 6 | # occurrences is achieved by looking at the hold space. 7 | /^msgid /{ 8 | x 9 | # Test if the hold space is empty. 10 | s/m/m/ 11 | ta 12 | # Yes it was empty. First occurrence. Read the file. 13 | r HEADER 14 | # Output the file's contents by reading the next line. But don't lose the 15 | # current line while doing this. 16 | g 17 | N 18 | bb 19 | :a 20 | # The hold space was nonempty. Following occurrences. Do nothing. 21 | x 22 | :b 23 | } 24 | -------------------------------------------------------------------------------- /po/quot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | -------------------------------------------------------------------------------- /po/remove-potcdate.sin: -------------------------------------------------------------------------------- 1 | # Sed script that remove the POT-Creation-Date line in the header entry 2 | # from a POT file. 3 | # 4 | # The distinction between the first and the following occurrences of the 5 | # pattern is achieved by looking at the hold space. 6 | /^"POT-Creation-Date: .*"$/{ 7 | x 8 | # Test if the hold space is empty. 9 | s/P/P/ 10 | ta 11 | # Yes it was empty. First occurrence. Remove the line. 12 | g 13 | d 14 | bb 15 | :a 16 | # The hold space was nonempty. Following occurrences. Do nothing. 17 | x 18 | :b 19 | } 20 | -------------------------------------------------------------------------------- /po/stamp-po: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /src/genmarshal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | glib-genmarshal --header --prefix ol_marshal marshal > ol_marshal.h 3 | glib-genmarshal --body --prefix ol_marshal marshal > ol_marshal.c 4 | 5 | -------------------------------------------------------------------------------- /src/marshal: -------------------------------------------------------------------------------- 1 | VOID:STRING,STRING 2 | VOID:UINT,DOUBLE 3 | -------------------------------------------------------------------------------- /src/ol_about.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include 21 | #include "config.h" 22 | #include "ol_intl.h" 23 | #include "ol_about.h" 24 | #include "ol_gui.h" 25 | #include "ol_debug.h" 26 | 27 | void ol_about_close_clicked (GtkWidget *widget); 28 | void ol_about_response (GtkDialog *dialog, gint response_id, gpointer user_data); 29 | 30 | void 31 | ol_about_response (GtkDialog *dialog, gint response_id, gpointer user_data) 32 | { 33 | ol_debugf ("response_id:%d\n", response_id); 34 | switch (response_id) 35 | { 36 | case GTK_RESPONSE_CANCEL: /* Close button in about dialog */ 37 | gtk_widget_hide (GTK_WIDGET (dialog)); 38 | break; 39 | } 40 | } 41 | 42 | void 43 | ol_about_close_clicked (GtkWidget *widget) 44 | { 45 | ol_log_func (); 46 | GtkWidget *toplevel = gtk_widget_get_toplevel (widget); 47 | if (GTK_WIDGET_TOPLEVEL (toplevel)) 48 | { 49 | gtk_widget_hide (toplevel); 50 | } 51 | } 52 | 53 | void 54 | ol_about_show () 55 | { 56 | static GtkWidget *window = NULL; 57 | if (window == NULL) 58 | { 59 | window = ol_gui_get_widget ("aboutdialog"); 60 | gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (window), PROGRAM_NAME); 61 | gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (window), VERSION); 62 | g_signal_connect (window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); 63 | GdkPixbuf *logo = gdk_pixbuf_new_from_file (ICONDIR "/osdlyrics.png", NULL); 64 | if (logo) 65 | { 66 | gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (window), 67 | logo); 68 | } 69 | } 70 | ol_assert (window != NULL); 71 | gtk_widget_show (GTK_WIDGET (window)); 72 | } 73 | -------------------------------------------------------------------------------- /src/ol_about.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_ABOUT_H_ 21 | #define _OL_ABOUT_H_ 22 | 23 | void ol_about_show (); 24 | 25 | #endif /* _OL_ABOUT_H_ */ 26 | -------------------------------------------------------------------------------- /src/ol_app.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_APP_H_ 21 | #define _OL_APP_H_ 22 | 23 | #include 24 | #include "ol_music_info.h" 25 | 26 | gboolean ol_app_download_lyric (OlMusicInfo *music_info); 27 | 28 | struct OlPlayer; 29 | struct OlLrc; 30 | 31 | /** 32 | * @brief Gets the current music 33 | * 34 | * @return 35 | */ 36 | OlMusicInfo* ol_app_get_current_music (void); 37 | 38 | struct OlPlayer* ol_app_get_player (void); 39 | 40 | struct OlLrc *ol_app_get_current_lyric (void); 41 | 42 | gboolean ol_app_assign_lrcfile (const OlMusicInfo *info, 43 | const char *filepath, 44 | gboolean update); 45 | /** 46 | * @brief Adjust the offset of lyric by offset_ms 47 | * 48 | * The offset of the lyric will be original offset + offset_ms 49 | * @param offset_ms Incremental value of offset, in milliseconds 50 | */ 51 | void ol_app_adjust_lyric_offset (int offset_ms); 52 | #endif /* _OL_APP_H_ */ 53 | -------------------------------------------------------------------------------- /src/ol_app_chooser_widget.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | 21 | #ifndef _OL_APP_CHOOSER_WIDGET_H_ 22 | #define _OL_APP_CHOOSER_WIDGET_H_ 23 | 24 | #include 25 | 26 | #define OL_TYPE_APP_CHOOSER_WIDGET \ 27 | ol_app_chooser_widget_get_type () 28 | #define OL_APP_CHOOSER_WIDGET(obj) \ 29 | GTK_CHECK_CAST (obj, OL_TYPE_APP_CHOOSER_WIDGET, OlAppChooserWidget) 30 | #define OL_APP_CHOOSER_WIDGET_CLASS(klass) \ 31 | GTK_CHECK_CLASS_CAST (klass, OL_TYPE_APP_CHOOSER_WIDGET, OlAppChooserWidgetClass) 32 | #define OL_IS_APP_CHOOSER_WIDGET(obj) \ 33 | GTK_CHECK_TYPE (obj, OL_TYPE_APP_CHOOSER_WIDGET) 34 | #define OL_APP_CHOOSER_WIDGET_GET_CLASS(obj) \ 35 | (G_TYPE_INSTANCE_GET_CLASS ((obj), \ 36 | OL_TYPE_APP_CHOOSER_WIDGET, \ 37 | OlAppChooserWidgetClass)) 38 | 39 | typedef struct _OlAppChooserWidget OlAppChooserWidget; 40 | typedef struct _OlAppChooserWidgetClass OlAppChooserWidgetClass; 41 | 42 | struct _OlAppChooserWidget 43 | { 44 | GtkTable parent; 45 | }; 46 | 47 | struct _OlAppChooserWidgetClass 48 | { 49 | GtkTableClass parent_class; 50 | }; 51 | 52 | GType ol_app_chooser_widget_get_type (void); 53 | 54 | GtkWidget *ol_app_chooser_widget_new (void); 55 | 56 | /** 57 | * Sets the app infos to the app chooser. 58 | * 59 | * @param chooser 60 | * @param app_list A GList of GAppInfo*. 61 | * @param n_columns The number of columns to show the apps. If it is set to 0, the 62 | * number of columns will be calculated according to the number 63 | * of apps. 64 | */ 65 | void ol_app_chooser_widget_set_app_list (OlAppChooserWidget *chooser, 66 | GList *app_list, 67 | guint n_columns); 68 | 69 | /** 70 | * Gets the number of columns of displayed apps. 71 | * 72 | * The number is guaranteed to be non-zero after setting the app_list. 73 | * @param chooser 74 | * 75 | * @return 76 | */ 77 | guint ol_app_chooser_widget_get_columns (OlAppChooserWidget *chooser); 78 | #endif /* _OL_APP_CHOOSER_WIDGET_H_ */ 79 | -------------------------------------------------------------------------------- /src/ol_cell_renderer_button.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_CELLRENDERERBUTTON_H_ 21 | #define _OL_CELLRENDERERBUTTON_H_ 22 | 23 | #include 24 | 25 | #define OL_TYPE_CELL_RENDERER_BUTTON (ol_cell_renderer_button_get_type ()) 26 | #define OL_CELL_RENDERER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OL_TYPE_CELL_RENDERER_BUTTON, OlCellRendererButton)) 27 | #define OL_CELL_RENDERER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OL_TYPE_CELL_RENDERER_BUTTON, OlCellRendererButtonClass)) 28 | #define OL_IS_CELL_RENDERER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OL_TYPE_CELL_RENDERER_BUTTON)) 29 | #define OL_IS_CELL_RENDERER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OL_TYPE_CELL_RENDERER_BUTTON)) 30 | #define OL_CELL_RENDERER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OL_TYPE_CELL_RENDERER_BUTTON, OlCellRendererButtonClass)) 31 | 32 | typedef struct _OlCellRendererButton OlCellRendererButton; 33 | typedef struct _OlCellRendererButtonClass OlCellRendererButtonClass; 34 | 35 | struct _OlCellRendererButton 36 | { 37 | GtkCellRenderer parent; 38 | 39 | /*< private >*/ 40 | gchar *GSEAL (text); 41 | gchar *GSEAL (stock_id); 42 | 43 | PangoFontDescription *GSEAL (font); 44 | /* gint GSEAL (rise); */ 45 | /* gint GSEAL (fixed_height_rows); */ 46 | 47 | }; 48 | 49 | struct _OlCellRendererButtonClass 50 | { 51 | GtkCellRendererClass parent_class; 52 | 53 | void (* edited) (OlCellRendererButton *cell_renderer_button, 54 | const gchar *path, 55 | const gchar *new_text); 56 | void (* clicked) (OlCellRendererButton *cell_renderer_button, 57 | const gchar *path); 58 | 59 | }; 60 | 61 | GType ol_cell_renderer_button_get_type (void) G_GNUC_CONST; 62 | GtkCellRenderer *ol_cell_renderer_button_new (void); 63 | 64 | #endif /* _OL_CELLRENDERERBUTTON_H_ */ 65 | -------------------------------------------------------------------------------- /src/ol_color.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include "ol_color.h" 20 | #include 21 | #include 22 | #include 23 | #include "ol_debug.h" 24 | 25 | OlColor 26 | ol_color_from_string (const char *color_str) 27 | { 28 | OlColor ret = ol_color_black; 29 | if (color_str == NULL) 30 | return ret; 31 | if (strlen (color_str) != 7) 32 | return ret; 33 | if (color_str[0] != '#') 34 | return ret; 35 | int i = 1; 36 | char colors[3][3] = {{0}}; 37 | for (i = 1; i < 7; i++) 38 | { 39 | if ((color_str[i] >= '0' && color_str[i] <= '9') || 40 | (color_str[i] >= 'a' && color_str[i] <= 'f') || 41 | (color_str[i] >= 'A' && color_str[i] <= 'F')) 42 | { 43 | colors[(i - 1) / 2][(i - 1) % 2] = color_str[i]; 44 | } 45 | else 46 | { 47 | return ret; 48 | } 49 | } 50 | unsigned int color_int[3]; 51 | for (i = 0; i < 3; i++) 52 | { 53 | sscanf (colors[i], "%x", &color_int[i]); 54 | } 55 | ret.r = color_int[0] / 255.0; 56 | ret.g = color_int[1] / 255.0; 57 | ret.b = color_int[2] / 255.0; 58 | return ret; 59 | } 60 | 61 | const char* 62 | ol_color_to_string (OlColor color) 63 | { 64 | static char ret[10] = ""; 65 | unsigned int r, g, b; 66 | r = color.r * 255; 67 | g = color.g * 255; 68 | b = color.b * 255; 69 | snprintf (ret, 10, "#%02x%02x%02x", r, g, b); 70 | ol_debugf ("color:%s\n", ret); 71 | return ret; 72 | } 73 | 74 | const OlColor ol_color_black = {0.0, 0.0, 0.0}; 75 | 76 | OlColor* 77 | ol_color_from_str_list (const char **str_list, int *len) 78 | { 79 | ol_assert_ret (str_list != NULL, NULL); 80 | int l = g_strv_length ((char**)str_list); 81 | OlColor *ret = g_new (OlColor, l); 82 | int i; 83 | for (i = 0; i < l; i++) 84 | { 85 | ret[i] = ol_color_from_string (str_list[i]); 86 | } 87 | if (len != NULL) 88 | *len = l; 89 | return ret; 90 | } 91 | 92 | char** 93 | ol_color_to_str_list (const OlColor *colors, int len) 94 | { 95 | ol_assert_ret (colors != NULL && len > 0, NULL); 96 | char **ret = g_new (char*, len + 1); 97 | ret[len] = NULL; 98 | int i; 99 | for (i = 0; i < len; i++) 100 | { 101 | ret[i] = g_strdup (ol_color_to_string (colors[i])); 102 | } 103 | return ret; 104 | } 105 | -------------------------------------------------------------------------------- /src/ol_color.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_COLOR_H_ 21 | #define _OL_COLOR_H_ 22 | 23 | typedef struct __OlColor 24 | { 25 | double r; 26 | double g; 27 | double b; 28 | } OlColor; 29 | 30 | /** 31 | * @brief Parse a string in the form of #RRGGBB and return the corresponding OlColor 32 | * 33 | * @param color_str The color string 34 | * 35 | * @return The corresponding color, if color_str is not a valid color string, 36 | * return black (result of #000000) 37 | */ 38 | OlColor ol_color_from_string (const char *color_str); 39 | 40 | /** 41 | * @brief Convert a color to a string in the form of #RRGGBB 42 | * 43 | * @param color The color to be converted 44 | * 45 | * @return The converted string. It belongs to the function and should not be 46 | * freed. It will be changed after another ol_color_to_string is called. 47 | */ 48 | const char* ol_color_to_string (OlColor color); 49 | 50 | /** 51 | * @brief Converts a string list to color array 52 | * 53 | * @param str_list String array, should be terminated with NULL 54 | * @param len Return location of the count of colors 55 | * 56 | * @return Color array, should be free with g_free, or NULL if failed 57 | */ 58 | OlColor* ol_color_from_str_list (const char **str_list, int *len); 59 | 60 | /** 61 | * @brief Converts a color array to NULL terminated string array 62 | * 63 | * @param colors An array of OlColor 64 | * @param len The length of colors 65 | * 66 | * @return NULL terminated string array, free with g_strfreev 67 | */ 68 | char** ol_color_to_str_list (const OlColor *colors, int len); 69 | 70 | extern const OlColor ol_color_black; 71 | 72 | #endif /* _OL_COLOR_H_ */ 73 | -------------------------------------------------------------------------------- /src/ol_commands.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include "ol_commands.h" 20 | #include "ol_config.h" 21 | #include "ol_debug.h" 22 | 23 | void 24 | ol_osd_lock_unlock () 25 | { 26 | OlConfig *config = ol_config_get_instance (); 27 | ol_assert (config != NULL); 28 | ol_config_set_bool (config, "OSD", "locked", !ol_config_get_bool (config, "OSD", "locked")); 29 | } 30 | 31 | void 32 | ol_show_hide () 33 | { 34 | OlConfig *config = ol_config_get_instance (); 35 | ol_assert (config != NULL); 36 | ol_config_set_bool (config, "General", "visible", !ol_config_get_bool (config, "General", "visible")); 37 | } 38 | -------------------------------------------------------------------------------- /src/ol_commands.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_commands.h 22 | * @author Tiger Soldier 23 | * @date Sun Aug 16 16:17:41 2009 24 | * 25 | * @brief Common operation on OSD Lyrics 26 | * 27 | * 28 | */ 29 | #ifndef _OL_COMMANDS_H_ 30 | #define _OL_COMMANDS_H_ 31 | 32 | /** 33 | * @brief switch lock/unlock status on OSD windows 34 | * 35 | */ 36 | void ol_osd_lock_unlock (); 37 | 38 | /** 39 | * @brief switch show/hide status 40 | * 41 | */ 42 | void ol_show_hide (); 43 | 44 | #endif /* _OL_COMMANDS_H_ */ 45 | -------------------------------------------------------------------------------- /src/ol_debug.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "ol_debug.h" 24 | 25 | #define COLOR_BOLD "\033[1m" 26 | #define COLOR_ITALIC "\033[3m" 27 | #define COLOR_RED "\033[31m" 28 | #define COLOR_YELLOW "\033[33m" 29 | #define COLOR_GREEN "\033[32m" 30 | #define COLOR_RESET "\033[0m" 31 | #define COLOR_ERROR COLOR_BOLD COLOR_RED 32 | #define COLOR_DEBUG COLOR_BOLD COLOR_YELLOW 33 | #define COLOR_INFO COLOR_BOLD COLOR_GREEN 34 | int gANSIEscapes = 0; 35 | static const char *LEVEL_MSG[] = { 36 | COLOR_ERROR "*Error*" COLOR_RESET, 37 | COLOR_DEBUG "*Debug*" COLOR_RESET, 38 | COLOR_INFO "*Info*" COLOR_RESET, 39 | }; 40 | 41 | static FILE *flog = NULL; 42 | static int debug_level = OL_ERROR; 43 | 44 | static int 45 | _ensure_flog () 46 | { 47 | if (flog == NULL) 48 | /* return ol_log_set_file ("-"); */ 49 | flog = stdout; 50 | return 1; 51 | } 52 | 53 | void 54 | ol_log_printf (int level, const char *file, int line, const char *funcname, 55 | const char *fmt, ...) 56 | { 57 | ol_assert (_ensure_flog ()); 58 | ol_assert (flog != NULL); 59 | ol_assert (level >= 0); 60 | ol_assert (level < OL_N_LEVELS); 61 | if (level > debug_level) 62 | return; 63 | va_list ap; 64 | va_start (ap, fmt); 65 | fprintf (flog, "%s: in function " COLOR_BOLD "%s" COLOR_RESET 66 | ": %s[%d]\n", 67 | LEVEL_MSG[level], funcname, file, line); 68 | vfprintf (flog, fmt, ap); 69 | va_end (ap); 70 | } 71 | 72 | void 73 | ol_log_set_level (enum OlDebugLevel level) 74 | { 75 | ol_assert (level >= -1); 76 | ol_assert (level < OL_N_LEVELS); 77 | debug_level = level; 78 | } 79 | 80 | int 81 | ol_log_set_file (const char *logfile) 82 | { 83 | ol_assert_ret (logfile != NULL, 0); 84 | if (flog != NULL) 85 | { 86 | fclose (flog); 87 | flog = NULL; 88 | } 89 | if (strcmp (logfile, "-") == 0) 90 | { 91 | flog = fdopen (STDOUT_FILENO, "w"); 92 | } 93 | else 94 | { 95 | flog = fopen (logfile, "w"); 96 | } 97 | return flog != NULL; 98 | } 99 | -------------------------------------------------------------------------------- /src/ol_elapse_emulator.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_elapse_emulator.h 22 | * @author Tiger Soldier 23 | * @date Sat Sep 12 23:22:30 2009 24 | * 25 | * @brief Elapsed time emulator that emulates elapsed time for those players who doesn't support elapsed time in millisecond 26 | * 27 | * 28 | */ 29 | #ifndef _OL_ELAPSE_EMULATOR_H_ 30 | #define _OL_ELAPSE_EMULATOR_H_ 31 | #include 32 | 33 | typedef struct _OlElapseEmulator OlElapseEmulator; 34 | 35 | struct _OlElapseEmulator 36 | { 37 | int first_time; 38 | int prev_time; 39 | int last_time; 40 | struct timeval begin_time; 41 | int accuracy; 42 | }; 43 | 44 | OlElapseEmulator *ol_elapse_emulator_new (int initial_time, int accuracy); 45 | void ol_elapse_emulator_free (OlElapseEmulator *emulator); 46 | void ol_elapse_emulator_init (OlElapseEmulator *emulator, 47 | int initial_time, 48 | int accuracy); 49 | int ol_elapse_emulator_get_real_ms (OlElapseEmulator *emulator, 50 | int time); 51 | int ol_elapse_emulator_get_last_ms (OlElapseEmulator *emulator, 52 | int time); 53 | 54 | #endif /* _OL_ELAPSE_EMULATOR_H_ */ 55 | -------------------------------------------------------------------------------- /src/ol_fork.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_fork.h 22 | * @author Tiger Soldier 23 | * @date Tue Jan 26 22:26:08 2010 24 | * 25 | * @brief The IPC mechanism receiving return data from child process 26 | * For the usage, see test/ol_fork_test.c 27 | * 28 | */ 29 | 30 | //@{ 31 | 32 | #ifndef _OL_FORK_H_ 33 | #define _OL_FORK_H_ 34 | #include 35 | #include 36 | 37 | extern int ret_fd; 38 | extern FILE *fret; 39 | 40 | /** 41 | * @brief Callback function of child process 42 | * 43 | * @param ret_data The data returned by child process 44 | * @param ret_size The number of bytes returned by child process 45 | * @param status Status information about the child process, 46 | * see waitpid(2) for more information about this field 47 | * @param userdata The user data passed in ol_fork 48 | * 49 | */ 50 | typedef void (*OlForkCallback) (void *ret_data, 51 | size_t ret_size, 52 | int status, 53 | void *userdata); 54 | 55 | /** 56 | * @brief Fork a child process 57 | * 58 | * To return data to parent process, child process just need to 59 | * write the return data to the file descriptor ret_fd, or to the 60 | * C file stream fret. 61 | * 62 | * Once the child process exits, the callback function will be 63 | * called. The child process is watched by g_child_watch_add, whose 64 | * source id will be returned in the watch_id. You can use g_source_remove 65 | * to cancel watching child process. 66 | * 67 | * @param callback Callback function 68 | * @param userdata Userdata to pass to callback function 69 | * @param watch_id source 70 | * 71 | * @return 0 if it's a child process, or the pid of the forked child process, 72 | * or -1 if failed without child process created 73 | */ 74 | pid_t ol_fork (OlForkCallback callback, void *userdata, guint *watch_id); 75 | //@} 76 | #endif /* _OL_FORK_H_ */ 77 | -------------------------------------------------------------------------------- /src/ol_gui.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include "ol_gui.h" 20 | #include "ol_intl.h" 21 | #include "ol_debug.h" 22 | 23 | const char *BUILDER_FILE = GUIDIR "/dialogs.glade"; 24 | static GtkBuilder *builder = NULL; 25 | 26 | static void internal_init (); 27 | 28 | static void 29 | internal_init () 30 | { 31 | if (builder == NULL) 32 | { 33 | builder = gtk_builder_new (); 34 | ol_assert (builder != NULL); 35 | gtk_builder_set_translation_domain (builder, PACKAGE); 36 | gtk_builder_add_from_file (builder, BUILDER_FILE, NULL); 37 | gtk_builder_connect_signals (builder, NULL); 38 | } 39 | } 40 | 41 | GtkWidget* 42 | ol_gui_get_widget (const char *name) 43 | { 44 | ol_assert_ret (name != NULL, NULL); 45 | internal_init (); 46 | ol_assert_ret (builder != NULL, NULL); 47 | GObject *obj = gtk_builder_get_object (builder, name); 48 | if (obj != NULL && GTK_IS_WIDGET (obj)) 49 | return GTK_WIDGET (obj); 50 | else 51 | return NULL; 52 | } 53 | -------------------------------------------------------------------------------- /src/ol_gui.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_GUI_H_ 21 | #define _OL_GUI_H_ 22 | 23 | #include 24 | 25 | /** 26 | * @brief Gets a widget in Glade file by name 27 | * 28 | * @param name name of the widget 29 | * 30 | * @return 31 | */ 32 | GtkWidget *ol_gui_get_widget (const char *name); 33 | 34 | #endif /* _OL_GUI_H_ */ 35 | -------------------------------------------------------------------------------- /src/ol_gussian_blur.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | 21 | #include 22 | 23 | /** 24 | * Apply Gussian blur to a cairo image surface 25 | * 26 | * @param surface A cairo image surface. Currently only an image surface in 27 | * CAIRO_FORMAT_ARGB32 format is supported. 28 | * @param sigma The variance of Gussian function. 29 | */ 30 | void ol_gussian_blur (cairo_surface_t *surface, 31 | double sigma); 32 | -------------------------------------------------------------------------------- /src/ol_image_button.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_IMAGE_BUTTON_H_ 21 | #define _OL_IMAGE_BUTTON_H_ 22 | 23 | #include 24 | 25 | #define OL_IMAGE_BUTTON(obj) GTK_CHECK_CAST (obj, ol_image_button_get_type (), OlImageButton) 26 | #define OL_IMAGE_BUTTON_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ol_image_button_get_type (), OlImageButtonClass) 27 | #define OL_IS_IMAGE_BUTTON(obj) GTK_CHECK_TYPE (obj, ol_image_button_get_type ()) 28 | #define OL_IMAGE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ol_image_button_get_type (), OlImageButtonClass)) 29 | 30 | typedef struct _OlImageButton OlImageButton; 31 | typedef struct _OlImageButtonClass OlImageButtonClass; 32 | 33 | struct _OlImageButton 34 | { 35 | GtkButton button; 36 | }; 37 | 38 | struct _OlImageButtonClass 39 | { 40 | GtkButtonClass button_class; 41 | }; 42 | 43 | GtkType ol_image_button_get_type (void); 44 | 45 | /** 46 | * @brief Create a new image button 47 | * 48 | * 49 | * @return A new instance of image button 50 | */ 51 | GtkWidget *ol_image_button_new (void); 52 | 53 | /** 54 | * @brief Sets the image of the button 55 | * 56 | * The image should contains 4 frames: normal, hover, pressed, disabled, from 57 | * left to right. The width of each frame must be equal. 58 | * 59 | * @param btn 60 | * @param image The image of the button 61 | */ 62 | void ol_image_button_set_pixbuf (OlImageButton *btn, GdkPixbuf *image); 63 | 64 | #endif /* _OL_IMAGE_BUTTON_H_ */ 65 | -------------------------------------------------------------------------------- /src/ol_intl.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_INTL_H_ 21 | #define _OL_INTL_H_ 22 | 23 | /* Internationalization. */ 24 | #include "config.h" 25 | #include "gettext.h" 26 | #define _(String) dgettext(PACKAGE,String) 27 | #define N_(String) (String) 28 | 29 | #endif /* _OL_INTL_H_ */ 30 | -------------------------------------------------------------------------------- /src/ol_keybinder.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file comes from the Tomboy project. 3 | // http://www.gnome.org/projects/tomboy/ 4 | // 5 | /* 6 | * Copyright (C) 2004-2007 Alex Graveley 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | */ 23 | 24 | #ifndef __DO_KEY_BINDER_H__ 25 | #define __DO_KEY_BINDER_H__ 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | typedef void (* OlBindkeyHandler) (char *keystring, gpointer user_data); 32 | 33 | void ol_keybinder_init (void); 34 | 35 | void ol_keybinder_bind (const char *keystring, 36 | OlBindkeyHandler handler, 37 | gpointer user_data); 38 | 39 | void ol_keybinder_unbind (const char *keystring, 40 | OlBindkeyHandler handler); 41 | 42 | gboolean ol_keybinder_is_modifier (guint keycode); 43 | 44 | guint32 ol_keybinder_get_current_event_time (void); 45 | 46 | G_END_DECLS 47 | 48 | #endif /* __DO_KEY_BINDER_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /src/ol_keybinding_settings.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_KEYBINDING_SETTING_H_ 21 | #define _OL_KEYBINDING_SETTING_H_ 22 | 23 | 24 | 25 | #endif /* _OL_KEYBINDING_SETTING_H_ */ 26 | -------------------------------------------------------------------------------- /src/ol_keybindings.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include "ol_keybindings.h" 20 | #include "ol_keybinding_settings.h" 21 | #include "ol_keybinder.h" 22 | #include "ol_commands.h" 23 | 24 | static GtkAccelGroup *accel = NULL; 25 | 26 | static void ol_hide_accel (gpointer userdata); 27 | 28 | static void 29 | ol_hide_accel (gpointer userdata) 30 | { 31 | } 32 | 33 | 34 | void 35 | ol_keybinding_init () 36 | { 37 | ol_keybinder_init (); 38 | GtkAccelGroup *accel = ol_keybinding_get_accel_group (); 39 | GClosure *hide_closure = g_cclosure_new ((GCallback)ol_hide_accel, 40 | NULL, 41 | NULL); 42 | gtk_accel_map_add_entry ("/Hide", 43 | gdk_keyval_from_name ("h"), 44 | GDK_CONTROL_MASK | GDK_SHIFT_MASK); 45 | gtk_accel_group_connect_by_path (accel, 46 | "/Hide", 47 | hide_closure); 48 | gtk_accel_map_add_entry ("/Lock", 49 | gdk_keyval_from_name ("l"), 50 | GDK_CONTROL_MASK | GDK_SHIFT_MASK); 51 | gtk_accel_group_connect_by_path (accel, 52 | "/Hide", 53 | hide_closure); 54 | ol_keybinder_bind ("H", ol_show_hide, NULL); 55 | ol_keybinder_bind ("L", ol_osd_lock_unlock, NULL); 56 | } 57 | 58 | GtkAccelGroup* 59 | ol_keybinding_get_accel_group () 60 | { 61 | if (accel == NULL) 62 | { 63 | accel = gtk_accel_group_new (); 64 | } 65 | return accel; 66 | } 67 | -------------------------------------------------------------------------------- /src/ol_keybindings.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_keybinding.h 22 | * @author Tiger Soldier 23 | * @date Sun Aug 16 15:58:56 2009 24 | * 25 | * @brief Global Keybinding settings 26 | */ 27 | #ifndef _OL_KEYBINDING_H_ 28 | #define _OL_KEYBINDING_H_ 29 | 30 | #include 31 | 32 | void ol_keybinding_init (); 33 | GtkAccelGroup* ol_keybinding_get_accel_group (); 34 | 35 | #endif /* _OL_KEYBINDING_H_ */ 36 | -------------------------------------------------------------------------------- /src/ol_lrc_candidate_list.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRC_CANDIDATE_LIST_H_ 21 | #define _OL_LRC_CANDIDATE_LIST_H_ 22 | 23 | #include 24 | #include "ol_lrc_fetch.h" 25 | 26 | void ol_lrc_candidate_list_init (GtkTreeView *list, 27 | GCallback select_change_callback); 28 | void ol_lrc_candidate_list_set_list (GtkTreeView *list, 29 | const OlLrcCandidate *candidates, 30 | int count); 31 | gboolean ol_lrc_candidate_list_get_selected (GtkTreeView *list, 32 | OlLrcCandidate *candidate); 33 | void ol_lrc_candidate_list_clear (GtkTreeView *list); 34 | 35 | #endif /* _OL_LRC_CANDIDATE_LIST_H_ */ 36 | -------------------------------------------------------------------------------- /src/ol_lrc_engine_list.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRC_ENGINE_LIST_H_ 21 | #define _OL_LRC_ENGINE_LIST_H_ 22 | 23 | #include 24 | #include "ol_lrc_fetch.h" 25 | 26 | void ol_lrc_engine_list_init (GtkTreeView *list); 27 | 28 | /** 29 | * Sets enabled engines with a list of name of engines. 30 | * 31 | * The enabled engines will be moved above disabled engines and sorted 32 | * according their position in the engine_list 33 | * @param list 34 | * @param engine_list A NULL-terminated string list with names of engines. 35 | * The caller is responsible for freeing it. 36 | */ 37 | void ol_lrc_engine_list_set_engine_names (GtkTreeView *list, 38 | char **engine_list); 39 | /** 40 | * Gets a list of name of enabled engines 41 | * 42 | * The returned list will be sorted according to their position in 43 | * the widget 44 | * 45 | * @param list The engine list widget 46 | * 47 | * @return A NULL-terminated string list with names of engines. 48 | * Should be freed with g_strfreev 49 | */ 50 | char **ol_lrc_engine_list_get_engine_names (GtkTreeView *list); 51 | 52 | #endif /* _OL_LRC_ENGINE_LIST_H_ */ 53 | -------------------------------------------------------------------------------- /src/ol_lrc_fetch_ttplayer.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRC_FETCH_TTPLAYER_H_ 21 | #define _OL_LRC_FETCH_TTPLAYER_H_ 22 | 23 | #include "ol_lrc_fetch.h" 24 | 25 | /** 26 | * @brief Returns the fetch engine of ttPlayer 27 | * 28 | * @return 29 | */ 30 | OlLrcFetchEngine *ol_lrc_fetch_ttplayer_engine (); 31 | 32 | #endif /* _OL_LRC_FETCH_TTPLAYER_H_ */ 33 | -------------------------------------------------------------------------------- /src/ol_lrc_fetch_ui.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRC_FETCH_UI_H_ 21 | #define _OL_LRC_FETCH_UI_H_ 22 | 23 | #include "ol_music_info.h" 24 | 25 | struct _OlLrcCandidate; 26 | struct _OlLrcFetchEngine; 27 | 28 | void ol_lrc_fetch_ui_show (struct _OlLrcFetchEngine *engine, 29 | const struct _OlLrcCandidate *candidates, 30 | int count, 31 | const OlMusicInfo *music_info, 32 | const char *filename); 33 | 34 | 35 | #endif /* _OL_LRC_FETCH_UI_H_ */ 36 | -------------------------------------------------------------------------------- /src/ol_lrc_fetch_xiami.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRC_FETCH_XIAMI_H_ 21 | #define _OL_LRC_FETCH_XIAMI_H_ 22 | 23 | #include "ol_lrc_fetch.h" 24 | 25 | /** 26 | * @brief Returns the fetch engine of Xiami 27 | * 28 | * @return 29 | */ 30 | OlLrcFetchEngine *ol_lrc_fetch_xiami_engine (); 31 | 32 | #endif /* _OL_LRC_FETCH_XIAMI_H_ */ 33 | -------------------------------------------------------------------------------- /src/ol_lrclib.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LRCLIB_H_ 21 | #define _OL_LRCLIB_H_ 22 | 23 | #include "ol_music_info.h" 24 | 25 | /** 26 | * @brief Initializes the Lrclib module 27 | * 28 | * @param filename The lrclib filename. 29 | * If not exists, a new one will be created 30 | * @return Non-zero if succeded. Otherwise returns 0. 31 | */ 32 | int ol_lrclib_init (const char *filename); 33 | 34 | /** 35 | * @brief Unload the Lrclib module. 36 | * 37 | * It will close the database. You should unload it before exit 38 | * 39 | */ 40 | void ol_lrclib_unload (); 41 | 42 | /** 43 | * @brief Assign an LRC file to a music 44 | * 45 | * @param info The music info to be assigned 46 | * @param lrcpath The LRC file, or NULL if no lyric should be assigned 47 | * 48 | * @return Non-zero if succeeded. 49 | */ 50 | int ol_lrclib_assign_lyric (const OlMusicInfo *info, 51 | const char *lrcpath); 52 | 53 | /** 54 | * @brief Find the lyric assigned to a music 55 | * 56 | * The lyric will be searched according to the file uri, then to the 57 | * combination of title, artist and album 58 | * 59 | * @param info The music info to be assigned 60 | * @param lrcpath The return loaction to the LRC File. This may be set to 61 | * NULL. If not NULL, it should be freed with 62 | * 63 | * @return Non-zero if succeeded. 0 if not found or error occured 64 | */ 65 | int ol_lrclib_find (const OlMusicInfo *info, 66 | char **lrcpath); 67 | #endif /* _OL_LRCLIB_H_ */ 68 | -------------------------------------------------------------------------------- /src/ol_lyric_manage.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_LYRIC_MANAGE_H_ 21 | #define _OL_LYRIC_MANAGE_H_ 22 | 23 | #include "ol_music_info.h" 24 | 25 | /** 26 | * @brief Find lyric file according to music info 27 | * 28 | * @param info 29 | * 30 | * @return If lyric file found, return the full path of the file. 31 | * Otherwise returns NULL. 32 | * The returned path should be freed with g_free. 33 | */ 34 | char *ol_lyric_find (OlMusicInfo *info); 35 | 36 | /** 37 | * @brief Get the full path to save the downloaded file 38 | * 39 | * @param info 40 | * 41 | * @return If a vaild path found, return the full path. 42 | * Otherwise returns NULL. 43 | * The returned path should be freed with g_free. 44 | */ 45 | char *ol_lyric_download_path (OlMusicInfo *info); 46 | #endif /* _OL_LYRIC_MANAGE_H_ */ 47 | -------------------------------------------------------------------------------- /src/ol_marshal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ol_marshal_MARSHAL_H__ 3 | #define __ol_marshal_MARSHAL_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | 9 | /* VOID:STRING,STRING (marshal:1) */ 10 | extern void ol_marshal_VOID__STRING_STRING (GClosure *closure, 11 | GValue *return_value, 12 | guint n_param_values, 13 | const GValue *param_values, 14 | gpointer invocation_hint, 15 | gpointer marshal_data); 16 | 17 | /* VOID:UINT,DOUBLE (marshal:2) */ 18 | extern void ol_marshal_VOID__UINT_DOUBLE (GClosure *closure, 19 | GValue *return_value, 20 | guint n_param_values, 21 | const GValue *param_values, 22 | gpointer invocation_hint, 23 | gpointer marshal_data); 24 | 25 | G_END_DECLS 26 | 27 | #endif /* __ol_marshal_MARSHAL_H__ */ 28 | 29 | -------------------------------------------------------------------------------- /src/ol_md5.h: -------------------------------------------------------------------------------- 1 | /* md5.h 2 | * 3 | * The MD5 hash function, described in RFC 1321. 4 | */ 5 | 6 | /* nettle, low-level cryptographics library 7 | * 8 | * Copyright (C) 2001 Niels Möller 9 | * 10 | * The nettle library is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at your 13 | * option) any later version. 14 | * 15 | * The nettle library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with the nettle library; see the file COPYING.LIB. If not, write to 22 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #ifndef NETTLE_MD5_H_INCLUDED 27 | #define NETTLE_MD5_H_INCLUDED 28 | 29 | #include 30 | 31 | /* Name mangling */ 32 | #define md5_init nettle_md5_init 33 | #define md5_update nettle_md5_update 34 | #define md5_digest nettle_md5_digest 35 | 36 | #define MD5_DIGEST_SIZE 16 37 | #define MD5_DATA_SIZE 64 38 | 39 | /* Digest is kept internally as 4 32-bit words. */ 40 | #define _MD5_DIGEST_LENGTH 4 41 | 42 | struct md5_ctx 43 | { 44 | guint32 digest[_MD5_DIGEST_LENGTH]; 45 | guint32 count_l, count_h; /* Block count */ 46 | guint8 block[MD5_DATA_SIZE]; /* Block buffer */ 47 | unsigned index; /* Into buffer */ 48 | }; 49 | 50 | void 51 | md5_init(struct md5_ctx *ctx); 52 | 53 | void 54 | md5_update(struct md5_ctx *ctx, 55 | unsigned length, 56 | const guint8 *data); 57 | 58 | void 59 | md5_digest(struct md5_ctx *ctx, 60 | unsigned length, 61 | guint8 *digest); 62 | 63 | #endif /* NETTLE_MD5_H_INCLUDED */ 64 | -------------------------------------------------------------------------------- /src/ol_menu.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_MENU_H_ 21 | #define _OL_MENU_H_ 22 | #include 23 | 24 | /** 25 | * @brief Gets singleton popup menu 26 | * The popup menu will be created at the first invoke 27 | * 28 | * @return The popup menu for the app 29 | */ 30 | GtkWidget* ol_menu_get_popup (); 31 | 32 | #endif /* _OL_MENU_H_ */ 33 | -------------------------------------------------------------------------------- /src/ol_notify.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_NOTIFY_H_ 21 | #define _OL_NOTIFY_H_ 22 | 23 | #include "ol_music_info.h" 24 | 25 | void ol_notify_init (void); 26 | void ol_notify_music_change (OlMusicInfo *info, const char *icon); 27 | void ol_notify_unload (void); 28 | 29 | #endif /* _OL_NOTIFY_H_ */ 30 | -------------------------------------------------------------------------------- /src/ol_option.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_OPTION_H_ 21 | #define _OL_OPTION_H_ 22 | 23 | void ol_option_show (); 24 | 25 | #endif /* _OL_OPTION_H_ */ 26 | -------------------------------------------------------------------------------- /src/ol_osd_module.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_OSD_MODULE_H_ 21 | #define _OL_OSD_MODULE_H_ 22 | 23 | #include "ol_display_module.h" 24 | 25 | struct OlDisplayClass* ol_osd_module_get_class (); 26 | 27 | #endif /* _OL_OSD_MODULE_H_ */ 28 | -------------------------------------------------------------------------------- /src/ol_osd_toolbar.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_OSD_TOOLBAR_H_ 21 | #define _OL_OSD_TOOLBAR_H_ 22 | 23 | #include 24 | #include "ol_player.h" 25 | 26 | #define OL_OSD_TOOLBAR(obj) GTK_CHECK_CAST (obj, ol_osd_toolbar_get_type (), OlOsdToolbar) 27 | #define OL_OSD_TOOLBAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ol_osd_toolbar_get_type (), OlOsdToolbarClass) 28 | #define OL_IS_OSD_TOOLBAR(obj) GTK_CHECK_TYPE (obj, ol_osd_toolbar_get_type ()) 29 | #define OL_OSD_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ol_osd_toolbar_get_type (), OlOsdToolbarClass)) 30 | 31 | typedef struct _OlOsdToolbar OlOsdToolbar; 32 | typedef struct _OlOsdToolbarClass OlOsdToolbarClass; 33 | 34 | struct _OlOsdToolbar 35 | { 36 | GtkAlignment alignment; 37 | GtkHBox *center_box; 38 | GtkButton *play_button; 39 | GtkButton *pause_button; 40 | GtkButton *prev_button; 41 | GtkButton *next_button; 42 | GtkButton *stop_button; 43 | }; 44 | 45 | struct _OlOsdToolbarClass 46 | { 47 | GtkAlignmentClass parent_class; 48 | }; 49 | 50 | GtkType ol_osd_toolbar_get_type (void); 51 | 52 | GtkWidget *ol_osd_toolbar_new (void); 53 | void ol_osd_toolbar_set_player (OlOsdToolbar *toolbar, struct OlPlayer *player); 54 | void ol_osd_toolbar_set_status (OlOsdToolbar *toolbar, enum OlPlayerStatus status); 55 | 56 | #endif /* _OL_OSD_TOOLBAR_H_ */ 57 | -------------------------------------------------------------------------------- /src/ol_player_amarok1.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_player_amarok1.h 22 | * @author Tiger Soldier 23 | * @date Mon May 18 13:55:29 2009 24 | * 25 | * @brief Provides support for Amarok1.4 26 | * 27 | * 28 | */ 29 | #ifndef _OL_PLAYER_AMAROK1_H_ 30 | #define _OL_PLAYER_AMAROK1_H_ 31 | 32 | #include "ol_player.h" 33 | 34 | /** 35 | * @brief Creates a controller of AmarOK1.4 36 | * 37 | * @return The controller of AmarOK1.4. It's allocated by g_new, so use g_free to free the memory 38 | */ 39 | struct OlPlayer* ol_player_amarok1_get (); 40 | 41 | 42 | #endif /* _OL_PLAYER_AMAROK1_H_ */ 43 | -------------------------------------------------------------------------------- /src/ol_player_banshee.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_PLAYER_BANSHEE_H__ 21 | #define __OL_PLAYER_BANSHEE_H__ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of Banshee 27 | * 28 | * @return The controller of Banshee. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_banshee_get (); 31 | 32 | #endif // __OL_PLAYER_BANSHEE_H__ 33 | -------------------------------------------------------------------------------- /src/ol_player_chooser.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_CHOOSER_H_ 21 | #define _OL_PLAYER_CHOOSER_H_ 22 | 23 | #include 24 | #define OL_PLAYER_CHOOSER(obj) GTK_CHECK_CAST (obj, ol_player_chooser_get_type (), OlPlayerChooser) 25 | #define OL_PLAYER_CHOOSER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ol_player_chooser_get_type (), OlPlayerChooserClass) 26 | #define OL_IS_PLAYER_CHOOSER(obj) GTK_CHECK_TYPE (obj, ol_player_chooser_get_type ()) 27 | #define OL_PLAYER_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ol_player_chooser_get_type (), OlPlayerChooserClass)) 28 | 29 | enum OlPlayerChooserResponse { 30 | OL_PLAYER_CHOOSER_RESPONSE_LAUNCH, 31 | }; 32 | 33 | enum OlPlayerChooserState { 34 | OL_PLAYER_CHOOSER_STATE_NO_PLAYER, 35 | OL_PLAYER_CHOOSER_STATE_CONNECTED, 36 | OL_PLAYER_CHOOSER_STATE_LAUNCH_FAIL, 37 | OL_PLAYER_CHOOSER_STATE_DISCONNECTED, 38 | }; 39 | 40 | typedef struct _OlPlayerChooser OlPlayerChooser; 41 | typedef struct _OlPlayerChooserClass OlPlayerChooserClass; 42 | 43 | struct _OlPlayerChooser 44 | { 45 | GtkDialog parent; 46 | }; 47 | 48 | struct _OlPlayerChooserClass 49 | { 50 | GtkDialogClass parent_class; 51 | }; 52 | 53 | GtkType ol_player_chooser_get_type (void); 54 | 55 | /** 56 | * Creates a new player chooser window. 57 | * 58 | * @param supported_players List of *GAppInfo. 59 | * 60 | * @return 61 | */ 62 | GtkWidget *ol_player_chooser_new (GList *supported_players); 63 | 64 | void ol_player_chooser_set_info (OlPlayerChooser *window, 65 | const char *title, 66 | const char *description); 67 | 68 | void ol_player_chooser_set_image_by_name (OlPlayerChooser *window, 69 | const char *icon_name); 70 | 71 | void ol_player_chooser_set_image_by_gicon (OlPlayerChooser *window, 72 | GIcon *icon); 73 | 74 | void ol_player_chooser_set_info_by_state (OlPlayerChooser *window, 75 | enum OlPlayerChooserState state); 76 | 77 | #endif /* _OL_PLAYER_CHOOSER_H_ */ 78 | -------------------------------------------------------------------------------- /src/ol_player_cmus.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2012 alepulver 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_CMUS_H_ 21 | #define _OL_PLAYER_CMUS_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of CMUS 27 | * 28 | * @return The controller of CMUS. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_cmus_get (); 31 | 32 | 33 | #endif /* _OL_PLAYER_CMUS_H_ */ 34 | -------------------------------------------------------------------------------- /src/ol_player_exaile02.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_PLAYER_EXAILE02_H__ 21 | #define __OL_PLAYER_EXAILE02_H__ 22 | #include "ol_player.h" 23 | 24 | struct OlPlayer* ol_player_exaile02_get (); 25 | 26 | #endif // __OL_PLAYER_EXAILE02_H__ 27 | -------------------------------------------------------------------------------- /src/ol_player_exaile03.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_PLAYER_EXAILE03_H__ 21 | #define __OL_PLAYER_EXAILE03_H__ 22 | #include "ol_player.h" 23 | 24 | struct OlPlayer* ol_player_exaile03_get (); 25 | 26 | #endif // __OL_PLAYER_EXAILE03_H__ 27 | -------------------------------------------------------------------------------- /src/ol_player_gmusicbrowser.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Sarlmol Apple 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file 22 | * @author sarlmolapple 23 | * @ 24 | */ 25 | 26 | 27 | #ifndef OL_PLAYER_GMUSICBROWSER_H 28 | #define OL_PLAYER_GMUSICBROWSER_H 29 | #include "ol_player.h" 30 | 31 | struct OlPlayer* ol_player_gmusicbrowser_get (); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/ol_player_juk.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_PLAYER_JUK_H__ 21 | #define __OL_PLAYER_JUK_H__ 22 | #include "ol_player.h" 23 | 24 | struct OlPlayer* ol_player_juk_get (); 25 | 26 | #endif // __OL_PLAYER_JUK_H__ 27 | -------------------------------------------------------------------------------- /src/ol_player_listen.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Sarlmol Apple 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file 22 | * @author Sarlmol Apple 23 | * @brief Supports Listen Music Player 24 | */ 25 | 26 | #ifndef _OL_PLAYER_LISTEN_H 27 | #define _OL_PLAYER_LISTEN_H 28 | #include "ol_player.h" 29 | 30 | struct OlPlayer* ol_player_listen_get (); 31 | 32 | #endif /* OL_PLAYER_LISTEN_H */ 33 | -------------------------------------------------------------------------------- /src/ol_player_moc.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_MOC_H_ 21 | #define _OL_PLAYER_MOC_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of MOC 27 | * 28 | * @return The controller of MOC. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_moc_get (); 31 | 32 | 33 | #endif /* _OL_PLAYER_MOC_H_ */ 34 | -------------------------------------------------------------------------------- /src/ol_player_mpd.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_PLAYER_MPD_H__ 21 | #define __OL_PLAYER_MPD_H__ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of Mpd 27 | * 28 | * @return The controller of Mpd. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_mpd_get (); 31 | 32 | #endif // __OL_PLAYER_MPD_H__ 33 | -------------------------------------------------------------------------------- /src/ol_player_mpris.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009 Tiger Soldier 4 | * Copyright (C) 2010 Sarlmol Apple 5 | * 6 | * This file is part of OSD Lyrics. 7 | * 8 | * OSD Lyrics is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * OSD Lyrics is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with OSD Lyrics. If not, see . 20 | */ 21 | 22 | /** 23 | * @file ol_player_mpris.h 24 | * @author Tiger Soldier 25 | * @date Sun Jun 7 16:53:56 2009 26 | * 27 | * @brief Supports all players that provides MPRIS interface 28 | * 29 | */ 30 | #ifndef _OL_PLAYER_MPRIS_H_ 31 | #define _OL_PLAYER_MPRIS_H_ 32 | 33 | struct OlPlayer* ol_player_mpris_get (void); 34 | 35 | #endif /* _OL_PLAYER_MPRIS_H_ */ 36 | -------------------------------------------------------------------------------- /src/ol_player_mpris2.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | 21 | /** 22 | * @file ol_player_mpris2.h 23 | * @author Tiger Soldier 24 | * @date Sun Jun 7 16:53:56 2009 25 | * 26 | * @brief Supports all players that provides MPRIS2 interface 27 | * 28 | */ 29 | #ifndef _OL_PLAYER_MPRIS2_H_ 30 | #define _OL_PLAYER_MPRIS2_H_ 31 | 32 | #include "ol_player.h" 33 | 34 | struct OlPlayer* ol_player_mpris2_get (); 35 | 36 | #endif /* _OL_PLAYER_MPRIS2_H_ */ 37 | -------------------------------------------------------------------------------- /src/ol_player_muine.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_MUINE_H_ 21 | #define _OL_PLAYER_MUINE_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of Muine 27 | * 28 | * @return The controller of Muine. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_muine_get (); 31 | 32 | #endif /* _OL_PLAYER_MUINE_H_ */ 33 | -------------------------------------------------------------------------------- /src/ol_player_quodlibet.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_QUODLIBET_H_ 21 | #define _OL_PLAYER_QUODLIBET_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | struct OlPlayer* ol_player_quodlibet_get (); 26 | 27 | #endif /* _OL_PLAYER_QUODLIBET_H_ */ 28 | -------------------------------------------------------------------------------- /src/ol_player_rhythmbox.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_RHYTHMBOX_H_ 21 | #define _OL_PLAYER_RHYTHMBOX_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | /** 26 | * @brief Creates a controller of Rhythmbox 27 | * 28 | * @return The controller of Rhythmbox. It's allocated by g_new, so use g_free to free the memory 29 | */ 30 | struct OlPlayer* ol_player_rhythmbox_get (); 31 | 32 | #endif /* _OL_PLAYER_RHYTHMBOX_H_ */ 33 | -------------------------------------------------------------------------------- /src/ol_player_rhythmcat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2011 Mike Ma 3 | * 4 | * This file is part of OSD Lyrics. 5 | * 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | 20 | 21 | #ifndef __OL_PLAYER_RHYTHMCAT_H__ 22 | #define __OL_PLAYER_RHYTHMCAT_H__ 23 | 24 | #include "ol_player.h" 25 | 26 | /** 27 | * @brief Creates a controller of RhythmCat 28 | * 29 | * @return The controller of RhythmCat. It's allocated by g_new, so use g_free to free the memory 30 | */ 31 | struct OlPlayer* ol_player_rhythmcat_get (); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/ol_player_utils.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #include 20 | #include 21 | #include "ol_player_utils.h" 22 | #include "ol_player.h" 23 | #include "ol_app_info.h" 24 | #include "ol_debug.h" 25 | 26 | GList * 27 | ol_player_get_app_info_list (struct OlPlayer *player, 28 | GList *list) 29 | { 30 | ol_assert_ret (player != NULL, list); 31 | const gchar *cmd = ol_player_get_cmd (player); 32 | if (cmd != NULL) 33 | { 34 | GError *error = NULL; 35 | OlAppInfo *info = ol_app_info_new (cmd, 36 | ol_player_get_name (player), 37 | ol_player_get_icon_path (player), 38 | OL_APP_INFO_PREFER_DESKTOP_FILE, 39 | &error); 40 | if (!info) 41 | { 42 | ol_errorf ("Cannot get player app info: %s\n", error->message); 43 | g_error_free (error); 44 | } 45 | else 46 | { 47 | list = g_list_prepend (list, info); 48 | } 49 | } 50 | return list; 51 | } 52 | -------------------------------------------------------------------------------- /src/ol_player_utils.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * OSD Lyrics is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * OSD Lyrics is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with OSD Lyrics. If not, see . 18 | */ 19 | #ifndef _OL_PLAYER_UTILS_H_ 20 | #define _OL_PLAYER_UTILS_H_ 21 | 22 | #include 23 | 24 | struct OlPlayer; 25 | 26 | /** 27 | * Prepend an GAppInfo to list according to the player commandline and name 28 | * 29 | * @param list The original list of pointer to GAppInfo 30 | * 31 | * @return The new list of pointer to GAppInfo 32 | */ 33 | GList *ol_player_get_app_info_list (struct OlPlayer *player, 34 | GList *list); 35 | 36 | #endif /* _OL_PLAYER_UTILS_H_ */ 37 | -------------------------------------------------------------------------------- /src/ol_player_xmms2.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_PLAYER_XMMS2_H_ 21 | #define _OL_PLAYER_XMMS2_H_ 22 | 23 | #include "ol_player.h" 24 | 25 | struct OlPlayer* ol_player_xmms2_get (); 26 | 27 | #endif /* _OL_PLAYER_XMMS2_H_ */ 28 | -------------------------------------------------------------------------------- /src/ol_scroll_module.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2010 Sarlmol Apple 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_SCROLL_MODULE_H_ 21 | #define _OL_SCROLL_MODULE_H_ 22 | 23 | #include "ol_display_module.h" 24 | 25 | struct OlDisplayClass* ol_scroll_module_get_class (); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/ol_search_dialog.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_SEARCH_DIALOG_H_ 21 | #define _OL_SEARCH_DIALOG_H_ 22 | 23 | void ol_search_dialog_show (); 24 | 25 | #endif /* _OL_SEARCH_DIALOG_H_ */ 26 | -------------------------------------------------------------------------------- /src/ol_singleton.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "ol_singleton.h" 28 | #include "config.h" 29 | #include "ol_debug.h" 30 | 31 | const char *LOCK_FILENAME = "singleton.lock"; 32 | 33 | /* Try to lock a file, From APUE */ 34 | int64_t 35 | _lockfile (int fd) 36 | { 37 | struct flock fl; 38 | fl.l_type = F_WRLCK; 39 | fl.l_start = 0; 40 | fl.l_whence = SEEK_SET; 41 | fl.l_len = 0; 42 | return (fcntl (fd, F_SETLK, &fl)); 43 | } 44 | 45 | int 46 | ol_is_running () 47 | { 48 | ol_log_func (); 49 | int ret = 1; 50 | char *dir = g_strdup_printf ("%s/%s/", g_get_user_config_dir (), PACKAGE_NAME); 51 | if (g_mkdir_with_parents (dir, 0755) == -1) 52 | { 53 | ol_error ("Failed to endure config dir"); 54 | } 55 | else 56 | { 57 | char *path = g_strdup_printf ("%s/%s/%s", g_get_user_config_dir (), PACKAGE_NAME, LOCK_FILENAME); 58 | int fd = open (path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); 59 | if (fd == -1) 60 | { 61 | ol_error ("Failed to open or create singleton lock"); 62 | } 63 | else 64 | { 65 | if (_lockfile (fd) < 0) 66 | { 67 | if (errno == EACCES || errno == EAGAIN) 68 | { 69 | close (fd); 70 | } 71 | ol_infof ("Can not lock file %s: %s\n", path, strerror (errno)); 72 | } 73 | else 74 | { 75 | if (ftruncate (fd, 0) != 0) 76 | { 77 | ol_errorf ("Failed to truncate singleton lock: %s\n", 78 | strerror (errno)); 79 | } 80 | char buf[16]; 81 | sprintf (buf, "%ld", (long)getpid ()); 82 | if (write (fd, buf, strlen (buf)) != strlen (buf)) 83 | ol_errorf ("Failed to write pid in singleton lock\n"); 84 | ret = 0; 85 | } 86 | } 87 | g_free (path); 88 | } 89 | g_free (dir); 90 | return ret; 91 | } 92 | -------------------------------------------------------------------------------- /src/ol_singleton.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_SINGLETON_H_ 21 | #define _OL_SINGLETON_H_ 22 | 23 | /** 24 | * @brief Check whether there is another instance running 25 | * 26 | * 27 | * @return 1 if there is another instance running, otherwise return 0. 28 | */ 29 | int ol_is_running (); 30 | 31 | #endif /* _OL_SINGLETON_H_ */ 32 | -------------------------------------------------------------------------------- /src/ol_stock.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include 21 | #include "ol_stock.h" 22 | 23 | 24 | static GtkIconFactory *icon_factory = NULL; 25 | const char *ICON_LIST[] = { 26 | OL_STOCK_TRAYICON, 27 | OL_STOCK_LOADING, 28 | OL_STOCK_OSD_BG, 29 | OL_STOCK_OSD_PLAY, 30 | OL_STOCK_OSD_PAUSE, 31 | OL_STOCK_OSD_STOP, 32 | OL_STOCK_OSD_PREV, 33 | OL_STOCK_OSD_NEXT, 34 | OL_STOCK_SCROLL_CLOSE, 35 | }; 36 | 37 | void 38 | ol_stock_init () 39 | { 40 | if (icon_factory == NULL) 41 | { 42 | icon_factory = gtk_icon_factory_new (); 43 | int i; 44 | for (i = 0; i < G_N_ELEMENTS (ICON_LIST); i++) 45 | { 46 | GtkIconSet *icon_set = gtk_icon_set_new (); 47 | GtkIconSource *icon_source = gtk_icon_source_new (); 48 | gtk_icon_source_set_icon_name (icon_source, 49 | ICON_LIST[i]); 50 | gtk_icon_set_add_source (icon_set, icon_source); 51 | gtk_icon_source_free (icon_source); 52 | gtk_icon_factory_add (icon_factory, 53 | ICON_LIST[i], 54 | icon_set); 55 | } 56 | gtk_icon_factory_add_default (icon_factory); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/ol_stock.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_STOCK_H_ 21 | #define _OL_STOCK_H_ 22 | 23 | #define OL_STOCK_TRAYICON "osdlyrics-trayicon" 24 | #define OL_STOCK_LOADING "osdlyrics-loading" 25 | #define OL_STOCK_OSD_BG "osdlyrics-osd-bg" 26 | #define OL_STOCK_OSD_PLAY "osdlyrics-osd-play" 27 | #define OL_STOCK_OSD_PAUSE "osdlyrics-osd-pause" 28 | #define OL_STOCK_OSD_STOP "osdlyrics-osd-stop" 29 | #define OL_STOCK_OSD_PREV "osdlyrics-osd-prev" 30 | #define OL_STOCK_OSD_NEXT "osdlyrics-osd-next" 31 | #define OL_STOCK_SCROLL_CLOSE "osdlyrics-scroll-close" 32 | void ol_stock_init (); 33 | 34 | #endif /* _OL_STOCK_H_ */ 35 | -------------------------------------------------------------------------------- /src/ol_trayicon.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef __OL_TRAYICON_H__ 21 | #define __OL_TRAYICON_H__ 22 | 23 | enum OlPlayerStatus; 24 | 25 | /** 26 | * @brief give a Entrance to do trayicon job 27 | * 28 | */ 29 | void ol_trayicon_inital (); 30 | 31 | /** 32 | * @brief Notifiy the trayicon that the playing status has changed 33 | * 34 | */ 35 | void ol_trayicon_status_changed (enum OlPlayerStatus status); 36 | 37 | void ol_trayicon_free (); 38 | #endif 39 | -------------------------------------------------------------------------------- /src/ol_utils_cmdline.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include /* For WEXITSTATUS */ 21 | #include "ol_utils_cmdline.h" 22 | #include "ol_debug.h" 23 | 24 | gboolean 25 | ol_cmd_get_string (const char *cmd, char **retval) 26 | { 27 | /* ol_log_func (); */ 28 | /* ol_debugf (" cmd: %s\n", cmd); */ 29 | ol_assert_ret (cmd != NULL, FALSE); 30 | int flags = 0; 31 | if (retval == NULL) 32 | flags |= G_SPAWN_STDOUT_TO_DEV_NULL; 33 | flags |= G_SPAWN_STDERR_TO_DEV_NULL; 34 | int exit_status; 35 | if (!g_spawn_command_line_sync (cmd, retval, NULL, &exit_status, NULL)) 36 | return FALSE; 37 | if (WEXITSTATUS(exit_status) != 0) 38 | return FALSE; 39 | return TRUE; 40 | } 41 | 42 | gboolean 43 | ol_cmd_get_int (const char *cmd, int *retval) 44 | { 45 | char *output; 46 | gboolean ret = ol_cmd_get_string (cmd, &output); 47 | if ((output != NULL) && (retval != NULL)) 48 | { 49 | sscanf (output, "%d", retval); 50 | } 51 | if (output != NULL) 52 | g_free (output); 53 | return ret; 54 | } 55 | 56 | gboolean 57 | ol_cmd_exec (const char *cmd) 58 | { 59 | char *output = NULL; 60 | gboolean ret = ol_cmd_get_string (cmd, &output); 61 | if (output != NULL) 62 | g_free (output); 63 | return ret; 64 | } 65 | -------------------------------------------------------------------------------- /src/ol_utils_cmdline.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_utils_cmdline.h 22 | * @author Tiger Soldier 23 | * @date Sat Jan 9 11:58:23 2010 24 | * 25 | * @brief Utilities for running applications from command line. 26 | * 27 | * 28 | */ 29 | 30 | #ifndef _OL_UTILS_CMDLINE_H_ 31 | #define _OL_UTILS_CMDLINE_H_ 32 | 33 | #include 34 | 35 | /** 36 | * @brief Execute a command and get its output as a string 37 | * 38 | * @param cmd The command to execute 39 | * @param retval The return location of the output string, or NULL. \ 40 | * Note: The passed string will NOT be freed. \ 41 | * The return string should be freed with g_free. 42 | * 43 | * @return If execute failed or the exit code of command is not 0, return FALSE 44 | */ 45 | gboolean ol_cmd_get_string (const char *cmd, char **retval); 46 | 47 | /** 48 | * @brief Execute a command and get its output as an integer 49 | * 50 | * @param cmd The command to execute 51 | * @param retval The return location of the output integer, or NULL. \ 52 | * If the output cannot be parsed as a number, it will remain what it was. 53 | * 54 | * @return If execute failed or the exit code of command is not 0, return FALSE 55 | */ 56 | gboolean ol_cmd_get_int (const char *cmd, int *retval); 57 | 58 | /** 59 | * @brief Execute a command and get its output as a string 60 | * 61 | * @param cmd The command to execute 62 | * 63 | * @return If execute failed or the exit code of command is not 0, return FALSE 64 | */ 65 | gboolean ol_cmd_exec (const char *cmd); 66 | 67 | #endif /* _OL_UTILS_CMDLINE_H_ */ 68 | -------------------------------------------------------------------------------- /src/ol_utils_dcop.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "ol_utils_dcop.h" 25 | #include "ol_debug.h" 26 | 27 | enum { 28 | BUFFER_SIZE = 512, 29 | }; 30 | 31 | gboolean 32 | ol_dcop_get_string (const gchar *cmd, gchar **returnval) 33 | { 34 | ol_assert_ret (cmd != NULL, FALSE); 35 | ol_assert_ret (returnval != NULL, FALSE); 36 | FILE *pPipe = popen (cmd, "r"); 37 | if (!pPipe) 38 | return FALSE; 39 | gchar buffer[BUFFER_SIZE] = ""; 40 | if (!fgets (buffer, BUFFER_SIZE, pPipe)) { 41 | pclose(pPipe); 42 | return FALSE; 43 | } 44 | pclose (pPipe); 45 | strtok (buffer,"\n"); 46 | if (*returnval != NULL) 47 | { 48 | g_free (*returnval); 49 | } 50 | *returnval = g_strdup (buffer); 51 | return TRUE; 52 | } 53 | 54 | gboolean 55 | ol_dcop_get_uint (const gchar *cmd, guint *returnval) 56 | { 57 | ol_assert_ret (cmd != NULL, FALSE); 58 | ol_assert_ret (returnval != NULL, FALSE); 59 | gchar *ret = NULL; 60 | if (!ol_dcop_get_string (cmd, &ret)) 61 | return FALSE; 62 | *returnval = atoi (ret); 63 | g_free (ret); 64 | return TRUE; 65 | } 66 | 67 | gboolean 68 | ol_dcop_get_boolean (const gchar *cmd, gboolean *returnval) 69 | { 70 | ol_log_func (); 71 | ol_assert_ret (cmd != NULL, FALSE); 72 | ol_assert_ret (returnval != NULL, FALSE); 73 | gchar *ret = NULL; 74 | if (!ol_dcop_get_string (cmd, &ret)) 75 | return FALSE; 76 | *returnval = (strcmp (ret, "true") == 0); 77 | ol_debugf ("returns %s\n", ret); 78 | g_free (ret); 79 | return TRUE; 80 | } 81 | -------------------------------------------------------------------------------- /src/ol_utils_dcop.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | /** 21 | * @file ol_utils_dcop.h 22 | * @author Tiger Soldier 23 | * @date Mon May 18 14:15:26 2009 24 | * 25 | * @brief Utilities for DCOP operation 26 | * 27 | * 28 | */ 29 | #ifndef _OL_UTILS_DCOP_H_ 30 | #define _OL_UTILS_DCOP_H_ 31 | /** 32 | * @brief Executes the command in cmd, fetch the output as a string and return it . 33 | * 34 | * @param cmd The DCOP command 35 | * @param returnval The point to the returned string, should be freed by g_free 36 | * 37 | * @return If succeeded, return TRUE 38 | */ 39 | gboolean ol_dcop_get_string (const gchar *cmd, gchar **returnval); 40 | 41 | gboolean ol_dcop_get_uint (const gchar *cmd, guint *returnval); 42 | 43 | gboolean ol_dcop_get_boolean (const gchar *cmd, gboolean *returnval); 44 | 45 | #endif /* _OL_UTILS_DCOP_H_ */ 46 | -------------------------------------------------------------------------------- /src/ol_utils_network.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #include "ol_utils_network.h" 21 | #include 22 | #include "ol_config.h" 23 | #include "ol_debug.h" 24 | 25 | static enum OlProxyType _get_proxy_type_from_system (); 26 | 27 | static enum OlProxyType 28 | _get_proxy_type_from_system () 29 | { 30 | /* TODO: We need to detect something like GNOME or KDE */ 31 | return OL_PROXY_ENVAR; 32 | } 33 | 34 | enum OlProxyType 35 | ol_get_proxy_type () 36 | { 37 | OlConfig *config = ol_config_get_instance (); 38 | char *proxy_setting = ol_config_get_string (config, "Download", "proxy"); 39 | enum OlProxyType type = OL_PROXY_NONE; 40 | if (proxy_setting != NULL && 41 | strcmp (proxy_setting, "system") == 0) 42 | { 43 | type = _get_proxy_type_from_system (); 44 | } 45 | else if (proxy_setting != NULL && 46 | strcmp (proxy_setting, "manual") == 0) 47 | { 48 | char *proxy_type = ol_config_get_string (config, "Download", "proxy-type"); 49 | if (proxy_type != NULL && strcmp (proxy_type, "socks4") == 0) 50 | type = OL_PROXY_SOCKS4; 51 | else if (proxy_type != NULL && strcmp (proxy_type, "socks5") == 0) 52 | type = OL_PROXY_SOCKS5; 53 | else 54 | type = OL_PROXY_HTTP; 55 | if (proxy_type != NULL) 56 | g_free (proxy_type); 57 | } 58 | if (proxy_setting != NULL) 59 | g_free (proxy_setting); 60 | return type; 61 | } 62 | 63 | char * 64 | ol_get_proxy_host () 65 | { 66 | /* TODO: detect GNOME or KDE */ 67 | OlConfig *config = ol_config_get_instance (); 68 | return ol_config_get_string (config, "Download", "proxy-host"); 69 | } 70 | 71 | int 72 | ol_get_proxy_port () 73 | { 74 | /* TODO: detect GNOME or KDE */ 75 | OlConfig *config = ol_config_get_instance (); 76 | return ol_config_get_int (config, "Download", "proxy-port"); 77 | } 78 | 79 | char * 80 | ol_get_proxy_username () 81 | { 82 | /* TODO: detect GNOME or KDE */ 83 | OlConfig *config = ol_config_get_instance (); 84 | return ol_config_get_string (config, "Download", "proxy-username"); 85 | } 86 | 87 | char * 88 | ol_get_proxy_password () 89 | { 90 | /* TODO: detect GNOME or KDE */ 91 | OlConfig *config = ol_config_get_instance (); 92 | return ol_config_get_string (config, "Download", "proxy-password"); 93 | } 94 | -------------------------------------------------------------------------------- /src/ol_utils_network.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */ 2 | /* 3 | * Copyright (C) 2009-2011 Tiger Soldier 4 | * 5 | * This file is part of OSD Lyrics. 6 | * 7 | * OSD Lyrics is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * OSD Lyrics is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with OSD Lyrics. If not, see . 19 | */ 20 | #ifndef _OL_UTILS_NETWORK_H_ 21 | #define _OL_UTILS_NETWORK_H_ 22 | 23 | enum OlProxyType { 24 | OL_PROXY_NONE, 25 | OL_PROXY_ENVAR, 26 | OL_PROXY_HTTP, 27 | OL_PROXY_SOCKS4, 28 | OL_PROXY_SOCKS5, 29 | }; 30 | 31 | enum OlProxyType ol_get_proxy_type (); 32 | char *ol_get_proxy_host (); 33 | int ol_get_proxy_port (); 34 | char *ol_get_proxy_username (); 35 | char *ol_get_proxy_password (); 36 | 37 | #endif /* _OL_UTILS_NETWORK_H_ */ 38 | -------------------------------------------------------------------------------- /src/tests/lrc_basic.lrc: -------------------------------------------------------------------------------- 1 | [attr1:] 2 | [attr2:value][attr3] 3 | 4 | [00:00.00]Text 1 5 | [01:34][02:33.26]中文歌词 6 | [03:04:05.06]另一个歌词[00:00] 7 | No tags 8 | -------------------------------------------------------------------------------- /src/tests/lrc_bom.lrc: -------------------------------------------------------------------------------- 1 | [00:17.20]雨淋湿了天空 毁得很讲究 2 | [00:22.30]你说你不懂 为何在这时牵手 3 | [00:26.43]我晒干了沉默 悔得很冲动 4 | [00:30.33]就算这是做错 也只是怕错过 5 | [00:35.50]在一起叫梦 分开了叫痛 6 | [00:38.65]是不是说 没有做完的梦最痛 7 | [00:42.80]迷路的后果 我能承受 8 | [00:46.62]这最后的出口 在爱过了才有 9 | [00:53.22]能不能给我一首歌的时间 10 | [00:57.20]紧紧的把那拥抱变成永远 11 | [01:01.27]在我的怀里你不用害怕失眠 12 | [01:05.44]如果你想忘记我也能失忆 13 | [01:09.45]能不能给我一首歌的时间 14 | [01:13.51]把故事听到最后才说再见 15 | [01:17.65]你送我的眼泪 让它留在雨天 16 | [01:21.65]越过你划的线 我定了勇气的终点 17 | [01:30.97]雨淋湿了天空 毁得很讲究 18 | [01:35.71]你说你不懂 为何在这时牵手 19 | [01:39.40]我晒干了沉默 悔得很冲动 20 | [01:43.80]就算这是做错 也只是怕错过 21 | [01:48.27]在一起叫梦 分开了叫痛 22 | [01:52.11]是不是说 没有做完的梦最痛 23 | [01:56.11]迷路的后果 我能承受 24 | [01:59.77]这最后的出口 在爱过了才有 25 | [02:06.26]能不能给我一首歌的时间 26 | [02:10.55]紧紧的把那拥抱变成永远 27 | [02:14.70]在我的怀里你不用害怕失眠 28 | [02:18.73]如果你想忘记我也能失忆 29 | [02:22.94]能不能给我一首歌的时间 30 | [02:26.84]把故事听到最后才说再见 31 | [02:30.90]你送我的眼泪 让它留在雨天 32 | [02:34.91]越过你划的线 我定了勇气的终点 33 | [02:43.22]你说我不该 不该 34 | [02:45.91]不该在这时候说了我爱你 35 | [02:52.06]要怎么证明我没有说谎的力气 36 | [02:59.10]请告诉我暂停算不算放弃 37 | [03:07.90]我只有一天的回忆 38 | [03:15.44]能不能给我一首歌的时间 39 | [03:19.64]紧紧的把那拥抱变成永远 40 | [03:23.54]在我的怀里你不用害怕失眠 41 | [03:27.60]如果你想忘记我也能失忆 42 | [03:31.94]能不能给我一首歌的时间 43 | [03:35.90]把故事听到最后才说再见 44 | [03:40.04]你送我的眼泪 让它留在雨天 45 | [03:44.84]越过你划的线 我定了勇气的终点 -------------------------------------------------------------------------------- /src/tests/lrc_gbk.lrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tigersoldier/osd-lyrics/c77209b8e322f95f4ab5721fd3348efee8def2f9/src/tests/lrc_gbk.lrc -------------------------------------------------------------------------------- /src/tests/lrc_no_newline.lrc: -------------------------------------------------------------------------------- 1 | [00:00.00]lyric -------------------------------------------------------------------------------- /src/tests/lrc_tail.lrc: -------------------------------------------------------------------------------- 1 | [10.00]begin 2 | [20.00]middle 3 | [30.00]end 4 | -------------------------------------------------------------------------------- /src/tests/lyric3.lrc: -------------------------------------------------------------------------------- 1 | [offset:-12345 -------------------------------------------------------------------------------- /src/tests/lyric4.lrc: -------------------------------------------------------------------------------- 1 | [10:10:10 invalid 2 | [1:1:1.1]lyric 3 | [1:2:3 another invalid -------------------------------------------------------------------------------- /src/tests/lyric_with_offset.lrc: -------------------------------------------------------------------------------- 1 | [al:] 2 | [title:] 3 | [offset:100] 4 | [0:00:01]foo 5 | -------------------------------------------------------------------------------- /src/tests/lyric_without_offset.lrc: -------------------------------------------------------------------------------- 1 | [al:] 2 | [title:] 3 | [0:00:01]foo 4 | -------------------------------------------------------------------------------- /src/tests/lyrics1.lrc: -------------------------------------------------------------------------------- 1 | [ti:] 2 | [ar:] 3 | [al:] 4 | [by:] 5 | 6 | [00:00.00]托す者へ~My Dear~ 7 | [00:05.28]圣斗士冥界篇ED 8 | [00:07.79]作词 车田正美·松尾康治 9 | [00:09.31]作曲 Kacky 编曲 Kacky&大石宪一郎 10 | [00:11.96]歌:松沢由美 11 | [00:13.00]制作:绯茶子殿下 12 | [00:14.47] 13 | [00:14.48]傷つき倒れた 14 | [00:19.42]戦士のはかない夢 15 | [00:25.74]枯野に咲く花 16 | [00:31.49]優しい笑顔 17 | [00:36.64] 18 | [00:36.65]遠く聞こえる 19 | [00:42.29]あの日の子守呗(ララバイ) 20 | [00:53.67]安らぎを ただ 求め 21 | [00:54.02]思い出を紡いでた 22 | [00:58.91] 23 | [00:58.92]この身が路傍(みち)に倒れていても 24 | [01:05.21]超えてゆけ わが友よ 25 | [01:10.58]涙枯れ果てたとしても 26 | [01:16.30]花は咲き宿す明日の生命(いのち) 27 | [01:25.43] 28 | [01:39.50]人は誰かを 29 | [01:44.11]傷つけ傷つけられ 30 | [01:50.51]逝くまで いくつの 31 | [01:56.08]傷を負うのだろう 32 | [02:01.40] 33 | [02:01.41]楽园を追われた 人の過ち 34 | [02:12.71]神の罰は いつまで 35 | [02:18.37]つづく果てなき闇 36 | [02:23.98] 37 | [02:23.99]星が流れ消えたとしても 38 | [02:29.98]嘆くまい わが友よ 39 | [02:35.38]あの日夜空に誓った夢は 40 | [02:40.99]うけつがれ永久に消えぬ光 41 | [02:51.27] 42 | [03:07.75]この身が路傍(みち)に倒れていても 43 | [03:13.71]超えてゆけ わが友よ 44 | [03:19.08]涙枯れ果てたとしても 45 | [03:24.64]花は咲き宿す明日の生命(いのち) 46 | [03:30.73]星が流れ消えたとしても 47 | [03:36.29]嘆くまい わが友よ 48 | [03:41.64]あの日夜空に誓った夢は 49 | [03:47.26]うけつがれ永久に消えぬ光 50 | [03:56.39]----------END---------- 51 | -------------------------------------------------------------------------------- /src/tests/mytest.lrc: -------------------------------------------------------------------------------- 1 | [ti:泪のムコウ] 2 | [ar:stereopony] 3 | [offset:102][00:00.17]谁かを悲しませてまで 笑えなくても 4 | [00:08.65] 5 | [00:08.85]そう言って彼女は うつむいてたんだ 6 | [00:11.98] 7 | [00:12.23]夜に泣いた 8 | [00:18.97] 9 | [00:19.28] 10 | [00:19.58]冷たく张り付いて冻えている 11 | [00:26.48] 12 | [00:26.95]降り続く现実に伞などない 13 | [00:33.46] 14 | [00:33.88]生きていく事が戦いなんて 15 | [00:40.00] 16 | [00:40.36]そんな理由だけで闭じ込められた 17 | [00:43.20] 18 | [00:43.78]マイハートマイストーリー 19 | [00:46.16]My heart my story 20 | [00:46.53] 21 | [00:46.89]泪のムコウが见えるの 辉いている 22 | [00:54.07] 23 | [00:54.58]いつか出会える仆らのために夜明けを待っている 24 | [01:00.95] 25 | [01:01.34]谁かを悲しませてまで 笑えなくても 26 | [01:08.42] 27 | [01:08.85]そう言って彼女は うつむいてたんだ 28 | [01:12.28] 29 | [01:12.61]マイストーリー 30 | [01:15.10]My story 31 | [01:17.66] 32 | [01:19.79] 33 | [01:20.05]月明かりぬれたまま 座り込んだ 34 | [01:26.74] 35 | [01:27.25]雨の街にあかりが 灯るみたいに 36 | [01:33.44] 37 | [01:33.93]生きてゆけばいい ただそれだけで 38 | [01:40.73] 39 | [01:41.11]どんな理由だってかまわないから 40 | [01:43.75] 41 | [01:44.08]マイハートマイストーリー 42 | [01:46.59]My heart my story 43 | [01:47.07] 44 | [01:47.55]泪のムコウが见えるの 辉いている 45 | [01:54.62] 46 | [01:55.05]ちいさな窓には あの顷みたいに 青い空がうつる 47 | [02:00.94] 48 | [02:01.43]ああ鸟のように飞べはしないけど 49 | [02:07.69]即使无法如鸟儿般飞翔 50 | [02:09.73] 51 | [02:12.81] 52 | [02:14.00]无理に笑うことないよ そのままでいいんだよ 53 | [02:27.09] 54 | [02:27.94]信じ続けてゆくだけ 55 | [02:34.06] 56 | [02:35.55]泪のムコウが见えるの 辉いている 57 | [02:42.75] 58 | [02:42.68]暗をくぐれば あの空はきっと七色に変わる 59 | [02:49.10] 60 | [02:49.54]谁かを悲しませたとき感じる痛み 61 | [02:57.00] 62 | [02:57.40]忘れないように そっと目を闭じて 泣いた 63 | [03:04.95] -------------------------------------------------------------------------------- /src/tests/ol_color_test.c: -------------------------------------------------------------------------------- 1 | #include "ol_color.h" 2 | #include 3 | 4 | void 5 | print_color (OlColor color) 6 | { 7 | printf ("OlColor color = {%lf, %lf, %lf}\n", color.r, color.g, color.b); 8 | } 9 | 10 | void 11 | test_from_str () 12 | { 13 | print_color (ol_color_from_string (NULL)); 14 | print_color (ol_color_from_string ("")); 15 | print_color (ol_color_from_string ("AABBCC")); 16 | print_color (ol_color_from_string ("#AAEEGG")); 17 | print_color (ol_color_from_string ("#000000")); 18 | print_color (ol_color_from_string ("#FFFFFF")); 19 | print_color (ol_color_from_string ("#ffffff")); 20 | print_color (ol_color_from_string ("#3377aA")); 21 | print_color (ol_color_from_string ("#abcdef")); 22 | print_color (ol_color_from_string ("#ABCDEF")); 23 | print_color (ol_color_from_string ("#123456")); 24 | print_color (ol_color_from_string ("#789aBc")); 25 | print_color (ol_color_from_string ("#0a0B0c")); 26 | } 27 | 28 | void 29 | test_to_str () 30 | { 31 | OlColor color1 = {0.000000, 0.000000, 0.000000}; 32 | ol_color_to_string (color1); 33 | OlColor color2 = {1.000000, 1.000000, 1.000000}; 34 | ol_color_to_string (color2); 35 | OlColor color3 = {0.200000, 0.466667, 0.666667}; 36 | ol_color_to_string (color3); 37 | OlColor color4 = {0.670588, 0.803922, 0.937255}; 38 | ol_color_to_string (color4); 39 | OlColor color5 = {0.039216, 0.043137, 0.047059}; 40 | ol_color_to_string (color5); 41 | OlColor color6 = {0.070588, 0.203922, 0.337255}; 42 | ol_color_to_string (color6); 43 | OlColor color7 = {0.470588, 0.603922, 0.737255}; 44 | ol_color_to_string (color7); 45 | } 46 | 47 | int 48 | main (int argc, char **argv) 49 | { 50 | test_from_str (); 51 | test_to_str (); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/tests/ol_config_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ol_config_test.c 3 | * @author Tiger Soldier 4 | * @date Sun Jun 21 08:26:35 2009 5 | * 6 | * @brief Unit test for OlConfig 7 | * 8 | * 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include "ol_config.h" 14 | 15 | void 16 | changed_handler (OlConfig *config, char *key, gpointer data) 17 | { 18 | printf ("%s has been changed\n", key); 19 | } 20 | 21 | void 22 | test_singleton () 23 | { 24 | printf ("%s\n", __FUNCTION__); 25 | OlConfig *config = ol_config_get_instance (); 26 | assert (config != NULL); 27 | OlConfig *config2 = ol_config_get_instance (); 28 | assert (config == config2); 29 | } 30 | 31 | void 32 | test_default_value () 33 | { 34 | printf ("%s\n", __FUNCTION__); 35 | OlConfig *config = ol_config_get_instance (); 36 | assert (config != NULL); 37 | ol_config_get_int (config, "OSD", "width"); 38 | ol_config_get_double (config, "OSD", "xalign"); 39 | ol_config_get_double (config, "OSD", "yalign"); 40 | ol_config_get_double (config, "OSD", "font-size"); 41 | ol_config_get_bool (config, "OSD", "locked"); 42 | g_free (ol_config_get_string (config, "OSD", "font-family")); 43 | g_strfreev (ol_config_get_str_list (config, "OSD", "active-lrc-color", NULL)); 44 | } 45 | 46 | void 47 | test_set_value () 48 | { 49 | const int INT_VAL = 10; 50 | const double DOUBLE_VAL = 0.75; 51 | const char* STR_VAL = "string test"; 52 | char *colors[] = {"#123456", "#7890ab", "#cdef01", NULL}; 53 | /* printf ("%s\n", __FUNCTION__); */ 54 | OlConfig *config = ol_config_get_instance (); 55 | assert (config != NULL); 56 | g_signal_connect (config, "changed", G_CALLBACK (changed_handler), NULL); 57 | ol_config_set_int (config, "OSD", "width", INT_VAL); 58 | assert (ol_config_get_int (config, "OSD", "width") == INT_VAL); 59 | ol_config_set_double (config, "OSD", "xalign", DOUBLE_VAL); 60 | assert (ol_config_get_double (config, "OSD", "xalign") == DOUBLE_VAL); 61 | ol_config_set_string (config, "OSD", "font-family", STR_VAL); 62 | assert (strcmp (ol_config_get_string (config, "OSD", "font-family"), STR_VAL) == 0); 63 | assert (strcmp (ol_config_get_string (config, "OSD", "font-family"), STR_VAL) == 0); 64 | ol_config_set_bool (config, "OSD", "locked", FALSE); 65 | assert (ol_config_get_bool (config, "OSD", "locked") == FALSE); 66 | ol_config_set_bool (config, "OSD", "locked", TRUE); 67 | assert (ol_config_get_bool (config, "OSD", "locked") == TRUE); 68 | ol_config_set_str_list (config, "OSD", "active-lrc-color", (const char **)colors, 3); 69 | g_strfreev (ol_config_get_str_list (config, "OSD", "active-lrc-color", NULL)); 70 | g_strfreev (ol_config_get_str_list (config, "OSD", "active-lrc-color", NULL)); 71 | } 72 | 73 | int 74 | main (int argc, char **argv) 75 | { 76 | gtk_init (&argc, &argv); 77 | test_singleton (); 78 | test_default_value (); 79 | test_set_value (); 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /src/tests/ol_fork_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define BUFFER_SIZE 1024 9 | 10 | void 11 | callback (void *ret_data, 12 | size_t ret_size, 13 | int status, 14 | void *data) 15 | { 16 | printf ("callback called\n"); 17 | printf ("return status: %d\n", WEXITSTATUS (status)); 18 | printf ("received: %s\n", (char*)ret_data); 19 | if (data != NULL) 20 | printf ("data: %s\n", (char *) data); 21 | } 22 | 23 | void 24 | test_normal () 25 | { 26 | static const char msg[] = "Fork Message"; 27 | printf ("Forking\n"); 28 | if (ol_fork (callback, (void*)msg, NULL) == 0) 29 | { 30 | sleep (2); 31 | fprintf (fret, msg); 32 | exit (0); 33 | } 34 | else 35 | { 36 | printf ("Fork succeeded\n"); 37 | } 38 | } 39 | 40 | void 41 | test_multiple_output () 42 | { 43 | printf ("Forking\n"); 44 | if (ol_fork (callback, NULL, NULL) == 0) 45 | { 46 | fprintf (fret, "Before Sleep\n"); 47 | sleep (2); 48 | fprintf (fret, "After Sleep\n"); 49 | exit (0); 50 | } 51 | else 52 | { 53 | printf ("Fork succeeded\n"); 54 | } 55 | } 56 | 57 | void 58 | test_no_output () 59 | { 60 | printf ("Forking\n"); 61 | if (ol_fork (callback, NULL, NULL) == 0) 62 | { 63 | exit (0); 64 | } 65 | else 66 | { 67 | printf ("Fork succeeded\n"); 68 | } 69 | } 70 | 71 | void 72 | test_exit_status () 73 | { 74 | printf ("Forking\n"); 75 | if (ol_fork (callback, NULL, NULL) == 0) 76 | { 77 | exit (10); 78 | } 79 | else 80 | { 81 | printf ("Fork succeeded\n"); 82 | } 83 | } 84 | 85 | int 86 | main (int argc, char **argv) 87 | { 88 | GMainLoop *loop = g_main_loop_new (NULL, FALSE); 89 | test_normal (); 90 | test_multiple_output (); 91 | test_no_output (); 92 | test_exit_status (); 93 | g_main_loop_run (loop); 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /src/tests/ol_gussian_blur_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ol_gussian_blur.h" 4 | 5 | static void 6 | banchmark () 7 | { 8 | cairo_surface_t *img = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 9 | 1000, 1000); 10 | ol_gussian_blur (img, 10); 11 | cairo_surface_destroy (img); 12 | } 13 | 14 | int 15 | main () 16 | { 17 | banchmark (); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/ol_lrc_fetch_check.c: -------------------------------------------------------------------------------- 1 | #include "ol_lrc_fetch.h" 2 | #include /* getopt */ 3 | #include 4 | #include 5 | #include 6 | 7 | #define OPTSTR "+t:s:h" 8 | const char *charset = "UTF-8"; 9 | 10 | void 11 | usage(void) 12 | { 13 | printf("LRC DOWNLOADER\n"); 14 | printf("usage: lrc_download -t title -s singer\n"); 15 | printf("usage: lrc_download -h\n"); 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | int ch, i, size, opt; 21 | char *title = NULL; 22 | char *singer = NULL; 23 | struct lrc_tsu *ret; 24 | 25 | if(argc <= 1) { 26 | usage(); 27 | exit(1); 28 | } 29 | 30 | opterr = 0; 31 | while((ch = getopt(argc, argv, OPTSTR)) != -1) { 32 | switch(ch) { 33 | case 't': 34 | title = optarg; 35 | break; 36 | case 's': 37 | singer = optarg; 38 | break; 39 | case 'h': 40 | usage(); 41 | exit(0); 42 | case '?': 43 | fprintf(stderr, "unknown option: -%c\n", optopt); 44 | usage(); 45 | exit(1); 46 | } 47 | } 48 | 49 | if(title==NULL && singer==NULL) { 50 | fprintf(stderr, "at least one of title and singer need to be NOT NULL\n"); 51 | exit(1); 52 | } 53 | 54 | ret = sogou.lrc_search(title, singer, &size); 55 | for(i=0; i 2 | #include 3 | #include 4 | #include "ol_lrc_fetch_ui.h" 5 | #include "ol_lrc_fetch.h" 6 | #define N_CANDIDATE 10 7 | 8 | void test_show () 9 | { 10 | OlLrcFetchEngine engine; 11 | OlLrcCandidate candidates[N_CANDIDATE + 1]; 12 | strcpy (candidates[0].title, "Tiger"); 13 | strcpy (candidates[0].artist, "Soldier"); 14 | strcpy (candidates[1].title, "All I Ask of You"); 15 | strcpy (candidates[1].artist, "Tiger Soldier & Christine"); 16 | int i; 17 | for (i = 2; i < N_CANDIDATE; i++) 18 | { 19 | sprintf (candidates[i].title, "Title #%d", i); 20 | sprintf (candidates[i].artist, "Artist #%d", i); 21 | } 22 | ol_lrc_fetch_ui_show (&engine, 23 | candidates, 24 | N_CANDIDATE, 25 | NULL, 26 | ""); 27 | gtk_main (); 28 | } 29 | 30 | int main (int argc, char **argv) 31 | { 32 | gtk_init (&argc, &argv); 33 | test_show (); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/tests/ol_lrc_file_test.c: -------------------------------------------------------------------------------- 1 | #include "ol_lrc_parser.h" 2 | #include "ol_debug.h" 3 | #include "ol_test_util.h" 4 | #include "ol_lrc_utility.h" 5 | 6 | void test () 7 | { 8 | ol_log_func (); 9 | LrcQueue *lrc = ol_lrc_parser_get_lyric_info ("lyric1.lrc"); 10 | LrcInfo *info = ol_lrc_parser_get_first_of_list (lrc); 11 | char *text = ol_lrc_parser_get_lyric_text (info); 12 | printf ("%s\n", text); 13 | ol_test_expect (strcmp (text, "托す者へ~My Dear~") == 0); 14 | double perc; 15 | int lrc_id; 16 | text = NULL; 17 | ol_lrc_utility_get_lyric_by_time (lrc, 26990, 9999999, text, &perc, &lrc_id); 18 | } 19 | 20 | void offset_without_right_bracket () 21 | { 22 | ol_log_func (); 23 | LrcQueue *lrc = ol_lrc_parser_get_lyric_info ("lyric3.lrc"); 24 | } 25 | 26 | void lack_of_right_bracket () 27 | { 28 | ol_log_func (); 29 | LrcQueue *lrc = ol_lrc_parser_get_lyric_info ("lyric4.lrc"); 30 | } 31 | 32 | void 33 | test_offset () 34 | { 35 | char *NO_OFFSET = "lyric_without_offset.lrc"; 36 | char *WITH_OFFSET = "lyric_with_offset.lrc"; 37 | ol_lrc_parser_set_lyric_file_offset (NO_OFFSET, 100); 38 | ol_lrc_parser_set_lyric_file_offset (WITH_OFFSET, -100); 39 | } 40 | 41 | int main() 42 | { 43 | /* test (); */ 44 | /* offset_without_right_bracket (); */ 45 | /* lack_of_right_bracket (); */ 46 | test_offset (); 47 | /* char test[100]= "mytest.lrc"; */ 48 | /* ol_lrc_parser_set_lyric_file_offset (test, 102); */ 49 | /* LrcQueue *list; */ 50 | /* list = ol_lrc_parser_get_lyric_info(test); */ 51 | /* printf ("offset:%d\n",list->offset); */ 52 | 53 | // printf("%d,%s", ol_lrc_parser_get_lyric_by_id(list,2)->lyric_time,ol_lrc_parser_get_lyric_by_id(list,6)->lyric_text); 54 | //printf("%s",test); 55 | // printf("%s",LoadFile(test)); 56 | 57 | /*char *lrcfile = LoadFile(test); 58 | LRC_QUEUE *List = malloc (((4+MAX_LINE_LEN+8)*MAX_LINE+6)*sizeof(char)); 59 | memset(List,0,((4+MAX_LINE_LEN+8)*MAX_LINE+6)); 60 | int filesize = strlen(lrcfile); 61 | // printf("%d",filesize); 62 | GetLrcInfo(lrcfile, filesize,List); 63 | int i=0;*/ 64 | /* LrcInfo *temp = &list->list[list->first]; 65 | 66 | int i=0; 67 | printf("%d\n",list->length); 68 | while(ilength) 69 | { 70 | printf("%d,%s,%d\n",temp->lyric_time,temp->lyric_text,temp->lyric_id); 71 | temp = temp->next; 72 | i++; 73 | } 74 | free (list);*/ 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/tests/ol_lrc_parser_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ol_lrc_parser.h" 4 | #include "ol_test_util.h" 5 | 6 | const char FILENAME[] = "lrc_gbk.lrc"; 7 | 8 | void print_token (union OlLrcToken *token) 9 | { 10 | switch (ol_lrc_token_get_type (token)) 11 | { 12 | case OL_LRC_TOKEN_TEXT: 13 | printf ("Text token: %s\n", token->text.text); 14 | break; 15 | case OL_LRC_TOKEN_ATTR: 16 | printf ("Attr token: attr: %s, value: %s\n", 17 | token->attr.attr, token->attr.value); 18 | break; 19 | case OL_LRC_TOKEN_TIME: 20 | printf ("Time token: %02d:%02d:%02d.%02d\n", 21 | token->time.time / 1000 / 60 / 60, 22 | token->time.time / 1000 / 60 % 60, 23 | token->time.time / 1000 % 60, 24 | token->time.time / 10 % 100); 25 | break; 26 | default: 27 | printf ("Invalid Token\n"); 28 | break; 29 | } 30 | } 31 | 32 | void general_test (struct OlLrcParser *parser) 33 | { 34 | union OlLrcToken *token = NULL; 35 | while ((token = ol_lrc_parser_next_token (parser)) != NULL) 36 | { 37 | print_token (token); 38 | ol_lrc_token_free (token); 39 | } 40 | } 41 | 42 | void test_file () 43 | { 44 | struct OlLrcParser *parser = ol_lrc_parser_new_from_file (FILENAME); 45 | general_test (parser); 46 | ol_lrc_parser_free (parser); 47 | } 48 | 49 | /* issue 80 */ 50 | void test_bom () 51 | { 52 | const char *FILENAME = "lrc_bom.lrc"; 53 | struct OlLrcParser *parser = ol_lrc_parser_new_from_file (FILENAME); 54 | union OlLrcToken *token = NULL; 55 | ol_test_expect ((token = ol_lrc_parser_next_token (parser)) != NULL); 56 | ol_test_expect (ol_lrc_token_get_type (token) == OL_LRC_TOKEN_TIME); 57 | ol_lrc_token_free (token); 58 | ol_lrc_parser_free (parser); 59 | } 60 | 61 | /* issue 113 */ 62 | void test_no_newline () 63 | { 64 | const char *FILENAME = "lrc_no_newline.lrc"; 65 | struct OlLrcParser *parser = ol_lrc_parser_new_from_file (FILENAME); 66 | union OlLrcToken *token = NULL; 67 | while ((token = ol_lrc_parser_next_token (parser)) != NULL) 68 | { 69 | if (ol_lrc_token_get_type (token) == OL_LRC_TOKEN_TEXT) 70 | ol_test_expect (strcmp (token->text.text, "lyric") == 0); 71 | ol_lrc_token_free (token); 72 | } 73 | ol_lrc_parser_free (parser); 74 | } 75 | 76 | int main() 77 | { 78 | test_file (); 79 | test_bom (); 80 | test_no_newline (); 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /src/tests/ol_lrc_utility_test.c: -------------------------------------------------------------------------------- 1 | #include "ol_lrc_utility.h" 2 | int main() 3 | { 4 | char test[100]= "mytest.lrc"; 5 | LrcQueue *list = ol_lrc_parser_get_lyric_info(test); 6 | int time = 189358; 7 | int end_time = 213028; 8 | char lyric_text[255] = ""; 9 | double percentage; 10 | int lyric_id; 11 | ol_lrc_utility_get_lyric_by_time(list,time,end_time,lyric_text,&percentage,&lyric_id); 12 | LrcInfo *info = ol_lrc_parser_get_lyric_by_id (list, lyric_id); 13 | if (info != NULL) 14 | printf("%d,%s,%lf",lyric_id,ol_lrc_parser_get_lyric_text (info),percentage); 15 | printf ("%d\n", lyric_id); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/ol_osd_window_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ol_osd_window.h" 4 | #include "ol_test_util.h" 5 | 6 | const char *LONG_LYRIC = "[00:24.85]我举杯 饮尽了风雪[00:31.01]是谁打翻前世柜 惹尘埃是非[00:37.26]缘字诀 几番轮回[00:41.39]你锁眉 哭红颜唤不回[00:47.45]纵然青史已经成灰 我爱不灭[00:54.82]繁华如三千东流水[00:58.97]我只取一瓢爱了解 只恋你化身的蝶[01:08.75]你发如雪 凄美了离别[01:13.44]我焚香感动了谁[01:18.07]邀明月 让回忆皎洁[01:22.20]爱在月光下完美[01:25.42]你发如雪 纷飞了眼泪[01:30.01]我等待苍老了谁[01:34.65]红尘醉 微醺的岁月[01:39.29]我用无悔 刻永世爱你的碑[01:43.39]Rap:[01:43.66]你发如雪 凄美了离别[01:45.97]我焚香感动了谁[01:47.62]邀明月 让回忆皎洁[01:49.79]爱在月光下完美[01:51.72]你发如雪 纷飞了眼泪[01:53.95]我等待苍老了谁[01:55.31]红尘醉 微醺的岁月[01:57.96][01:59.44]狼牙月 伊人憔悴[02:03.53]我举杯 饮尽了风雪[02:09.65]是谁打翻前世柜 惹尘埃是非[02:15.99]缘字诀 几番轮回[02:20.14]你锁眉 哭红颜唤不回[02:26.14]纵然青史已经成灰 我爱不灭[02:33.58]繁华如三千东流水[02:37.72]我只取一瓢爱了解 只恋你化身的蝶[02:47.31]你发如雪 凄美了离别[02:52.20]我焚香感动了谁[02:56.83]邀明月 让回忆皎洁[03:01.01]爱在月光下完美[03:04.14]你发如雪 纷飞了眼泪[03:08.76]我等待苍老了谁[03:14.12]红尘醉 微醺的岁月[03:18.74]我用无悔 刻永世爱你的碑[03:22.31]Rap:[03:23.08]你发如雪 凄美了离别[03:25.10]我焚香感动了谁[03:27.26]邀明月 让回忆皎洁[03:29.36]爱在月光下完美[03:31.32]你发如雪 纷飞了眼泪[03:33.55]我等待苍老了谁[03:35.85]红尘醉 微醺的岁月[03:37.70][03:38.47]你发如雪 凄美了离别[03:42.93]我焚香感动了谁[03:47.50]邀明月 让回忆皎洁[03:51.68]爱在月光下完美[03:54.78]你发如雪 纷飞了眼泪[03:59.44]我等待苍老了谁[04:03.59]红尘醉 微醺的岁月[04:08.74]我用无悔 刻永世爱你的碑[04:13.37]啦儿啦 啦儿啦 啦儿啦儿啦[04:17.21]啦儿啦 啦儿啦 啦儿啦儿啦[04:21.71]铜镜映无邪 扎马尾 你若撒野[04:26.96]今生我把酒奉陪[04:30.02]啦儿啦 啦儿啦 啦儿啦儿啦[04:33.70]啦儿啦 啦儿啦 啦儿啦儿啦[04:38.21]铜镜映无邪 扎马尾 你若撒野[04:43.51]今生我把酒奉陪[04:48.79]END"; 7 | 8 | void 9 | basic_test () 10 | { 11 | GtkWidget *window = ol_osd_window_new (); 12 | gtk_widget_show (window); 13 | gtk_widget_destroy (window); 14 | } 15 | 16 | void 17 | long_lyric_test () 18 | { 19 | GtkWidget *window = ol_osd_window_new (); 20 | gtk_widget_show (window); 21 | ol_osd_window_set_lyric (OL_OSD_WINDOW (window), 0, LONG_LYRIC); 22 | g_timeout_add (2000, (GSourceFunc)gtk_main_quit, NULL); 23 | gtk_main (); 24 | gtk_widget_destroy (window); 25 | } 26 | 27 | int 28 | main (int argc, char **argv) 29 | { 30 | gtk_init (&argc, &argv); 31 | basic_test (); 32 | long_lyric_test (); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/tests/ol_path_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ol_path_pattern.h" 4 | #include "ol_music_info.h" 5 | #include "ol_test_util.h" 6 | 7 | #define BUFFER_SIZE 1024 8 | 9 | static void 10 | check_expand_file () 11 | { 12 | printf ("%s\n", __FUNCTION__); 13 | OlMusicInfo info; 14 | ol_music_info_init (&info); 15 | info.title = "Title"; 16 | info.artist = "Artist"; 17 | info.uri = "file:///path-to-uri/filename.ext"; 18 | info.album = "Album"; 19 | info.track_number = 12; 20 | char buffer[BUFFER_SIZE]; 21 | char pattern[][1024] = { 22 | "%p - %t", 23 | "%n%p%t%a" 24 | }; 25 | char result[][1024] = { 26 | "Artist - Title", 27 | "12ArtistTitleAlbum", 28 | }; 29 | int i; 30 | for (i = 0; i < 2; i++) 31 | { 32 | ol_path_expand_file_pattern (pattern[i], 33 | &info, 34 | buffer, 35 | BUFFER_SIZE); 36 | ol_test_expect (strcmp (buffer, result[i]) == 0); 37 | } 38 | info.uri = "file:///home/tiger/Music/Bandari/heaven_blue/11.SONG%20OF%20THE%20MAYAS.mp3"; 39 | ol_path_expand_file_pattern ("%f", &info, buffer, BUFFER_SIZE); 40 | ol_test_expect (strcmp (buffer, "11.SONG OF THE MAYAS") == 0); 41 | } 42 | 43 | void 44 | check_expand_path () 45 | { 46 | printf ("%s\n", __FUNCTION__); 47 | const char absolute[] = "/path/to/lyric/"; 48 | const char relative[] = "~/.lyrics/"; 49 | const char from_uri[] = "%"; 50 | const char empty_uri[] = ""; 51 | char buffer[BUFFER_SIZE] = ""; 52 | OlMusicInfo info; 53 | ol_music_info_init (&info); 54 | info.uri = "file:///home/tiger/Music/Bandari/heaven_blue/11.SONG%20OF%20THE%20MAYAS.mp3"; 55 | ol_path_expand_path_pattern (absolute, NULL, buffer, BUFFER_SIZE); 56 | ol_test_expect (strcmp (buffer, absolute) == 0); 57 | ol_path_expand_path_pattern (relative, NULL, buffer, BUFFER_SIZE); 58 | printf (" %s\n", buffer); 59 | ol_path_expand_path_pattern (from_uri, &info, buffer, BUFFER_SIZE); 60 | ol_test_expect (strcmp (buffer, "/home/tiger/Music/Bandari/heaven_blue") == 0); 61 | ol_path_expand_path_pattern (empty_uri, &info, buffer, BUFFER_SIZE); 62 | ol_test_expect (strcmp (buffer, empty_uri) == 0); 63 | } 64 | 65 | /* issue */ 66 | void 67 | check_expand_nouri () 68 | { 69 | printf ("%s\n", __FUNCTION__); 70 | const char from_uri[] = "%"; 71 | char buffer[BUFFER_SIZE] = ""; 72 | OlMusicInfo info; 73 | ol_music_info_init (&info); 74 | info.uri = "/path/of/file/name"; 75 | ol_test_expect (ol_path_expand_path_pattern (from_uri, &info, buffer, BUFFER_SIZE) > 0); 76 | ol_test_expect (strcmp (buffer, "/path/of/file") == 0); 77 | } 78 | 79 | int 80 | main () 81 | { 82 | check_expand_file (); 83 | check_expand_path (); 84 | check_expand_nouri (); 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /src/tests/ol_test_util.h: -------------------------------------------------------------------------------- 1 | #ifndef _OL_TEST_UTIL_H_ 2 | #define _OL_TEST_UTIL_H_ 3 | 4 | #include 5 | 6 | #define ol_test_expect(expr) \ 7 | if (!(expr)) \ 8 | { printf ("ERROR[%d]: EXPECT %s failed\n", __LINE__, #expr); } 9 | 10 | #define ol_test_expect_streq(expr1, expr2) \ 11 | ol_test_expect (strcmp ((expr1), (expr2)) == 0) 12 | 13 | #endif /* _OL_TEST_UTIL_H_ */ 14 | -------------------------------------------------------------------------------- /src/tests/ol_utils_cmdline_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ol_utils_cmdline.h" 4 | #include "ol_test_util.h" 5 | 6 | void 7 | test_string () 8 | { 9 | char *string = g_strdup ("Tiger Soldier"); 10 | char *strold = string; 11 | gboolean ret = ol_cmd_get_string ("echo Cmd test", &string); 12 | ol_test_expect (ret == TRUE); 13 | ol_test_expect (strcmp (string, "Cmd test\n") == 0); 14 | if (string) 15 | g_free (string); 16 | ol_test_expect (strcmp (strold, "Tiger Soldier") == 0); 17 | g_free (strold); 18 | } 19 | 20 | void 21 | test_null_string () 22 | { 23 | gboolean ret = ol_cmd_get_string ("ls", NULL); 24 | ol_test_expect (ret == TRUE); 25 | } 26 | 27 | void 28 | test_int () 29 | { 30 | int sum; 31 | const char *cmd = "expr 3 + 2"; 32 | const int ans = 5; 33 | gboolean ret = ol_cmd_get_int (cmd, &sum); 34 | ol_test_expect (ret == TRUE); 35 | ol_test_expect (sum == ans); 36 | ret = ol_cmd_get_int ("/home/", &sum); 37 | ol_test_expect (ret == FALSE); 38 | ol_test_expect (sum == ans); 39 | ret = ol_cmd_get_int ("pgrep init", &sum); 40 | ol_test_expect (ret == TRUE); 41 | ret = ol_cmd_get_int ("pgrep /asdf/", &sum); 42 | ol_test_expect (ret == FALSE); 43 | } 44 | 45 | int 46 | main () 47 | { 48 | test_string (); 49 | test_null_string (); 50 | test_int (); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /src/tests/ol_utils_dbus_test.c: -------------------------------------------------------------------------------- 1 | #include "ol_utils_dbus.h" 2 | #include "ol_test_util.h" 3 | 4 | void 5 | test_list_name () 6 | { 7 | char **names = ol_dbus_list_names (); 8 | ol_test_expect (names != NULL); 9 | g_strfreev (names); 10 | } 11 | 12 | void 13 | test_prop () 14 | { 15 | DBusGProxy *proxy = NULL; 16 | if (!ol_dbus_connect ("org.mpris.MediaPlayer2.rhythmbox", 17 | "/org/mpris/MediaPlayer2", 18 | "org.mpris.MediaPlayer2.Player", 19 | NULL, 20 | NULL, 21 | &proxy)) 22 | { 23 | printf ("You need to launch Rhythmbox in order to test dbus property\n"); 24 | } 25 | else 26 | { 27 | gboolean canplay = FALSE; 28 | ol_test_expect (ol_dbus_get_bool_property (proxy, "CanPlay", &canplay)); 29 | ol_test_expect (canplay); 30 | GHashTable *metadata = NULL; 31 | ol_test_expect (ol_dbus_get_dict_property (proxy, "Metadata", &metadata)); 32 | ol_test_expect (metadata != NULL); 33 | printf("%d\n", g_hash_table_size (metadata)); 34 | g_object_unref (proxy); 35 | } 36 | } 37 | 38 | int 39 | main () 40 | { 41 | g_type_init (); 42 | test_list_name (); 43 | test_prop (); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /src/tests/ol_utils_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ol_utils.h" 5 | #include "ol_debug.h" 6 | #include "ol_test_util.h" 7 | 8 | void 9 | g_value_free (GValue *value) 10 | { 11 | g_value_unset (value); 12 | g_free (value); 13 | } 14 | 15 | void 16 | test_hashtable (void) 17 | { 18 | static const int INT_VALUE = 23840; 19 | static const char *STR_VALUE = "String Value"; 20 | static char *STRV_VALUE[] = { 21 | "Str1", 22 | "Str2", 23 | NULL, 24 | }; 25 | GHashTable *ht = g_hash_table_new_full (g_str_hash, g_str_equal, 26 | g_free, (GDestroyNotify)g_value_free); 27 | GValue *value = g_new0 (GValue, 1); 28 | g_value_init (value, G_TYPE_INT); 29 | g_value_set_int (value, INT_VALUE); 30 | g_hash_table_insert (ht, g_strdup ("int"), value); 31 | 32 | value = g_new0 (GValue, 1); 33 | g_value_init (value, G_TYPE_STRING); 34 | g_value_set_string (value, STR_VALUE); 35 | g_hash_table_insert (ht, g_strdup ("str"), value); 36 | 37 | value = g_new0 (GValue, 1); 38 | g_value_init (value, G_TYPE_STRV); 39 | g_value_set_boxed (value, STRV_VALUE); 40 | g_hash_table_insert (ht, g_strdup ("strv"), value); 41 | 42 | ol_test_expect (ol_get_int_from_hash_table (ht, "int") == INT_VALUE); 43 | 44 | ol_test_expect (strcmp (ol_get_string_from_hash_table (ht, "str"), STR_VALUE) == 0); 45 | 46 | ol_test_expect (g_strv_length (ol_get_str_list_from_hash_table (ht, "strv")) == 47 | g_strv_length (STRV_VALUE)); 48 | 49 | ol_test_expect (ol_get_int_from_hash_table (ht, "str") == -1); 50 | ol_test_expect (ol_get_int_from_hash_table (ht, "not_exists") == -1); 51 | 52 | ol_test_expect (ol_get_string_from_hash_table (ht, "int") == NULL); 53 | ol_test_expect (ol_get_string_from_hash_table (ht, "not_exists") == NULL); 54 | 55 | ol_test_expect (ol_get_str_list_from_hash_table (ht, "str") == NULL); 56 | ol_test_expect (ol_get_str_list_from_hash_table (ht, "not_exists") == NULL); 57 | 58 | g_hash_table_destroy (ht); 59 | } 60 | 61 | static gboolean 62 | traverse_func (const char *path, 63 | const char *filename, 64 | gpointer data) 65 | { 66 | ol_test_expect (GPOINTER_TO_INT (data) == 123); 67 | gchar *fullpath = g_build_path (G_DIR_SEPARATOR_S, path, filename, NULL); 68 | ol_test_expect (g_file_test (fullpath, G_FILE_TEST_EXISTS)); 69 | g_free (fullpath); 70 | return TRUE; 71 | } 72 | 73 | static void 74 | test_traverse (void) 75 | { 76 | ol_traverse_dir ("/usr/bin", 77 | FALSE, 78 | traverse_func, 79 | GINT_TO_POINTER (123)); 80 | } 81 | 82 | int 83 | main (int argc, char **argv) 84 | { 85 | g_type_init (); 86 | ol_log_set_file ("-"); 87 | test_hashtable (); 88 | test_traverse (); 89 | return 0; 90 | } 91 | --------------------------------------------------------------------------------