From 793cf2dff35dffe3ec4c7b24252947dde758a1b2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:04:32 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdefile-plugins/sid/Makefile.am | 22 ++++ tdefile-plugins/sid/tdefile_sid.cpp | 227 ++++++++++++++++++++++++++++++++ tdefile-plugins/sid/tdefile_sid.desktop | 60 +++++++++ tdefile-plugins/sid/tdefile_sid.h | 43 ++++++ 4 files changed, 352 insertions(+) create mode 100644 tdefile-plugins/sid/Makefile.am create mode 100644 tdefile-plugins/sid/tdefile_sid.cpp create mode 100644 tdefile-plugins/sid/tdefile_sid.desktop create mode 100644 tdefile-plugins/sid/tdefile_sid.h (limited to 'tdefile-plugins/sid') diff --git a/tdefile-plugins/sid/Makefile.am b/tdefile-plugins/sid/Makefile.am new file mode 100644 index 00000000..56bfa54f --- /dev/null +++ b/tdefile-plugins/sid/Makefile.am @@ -0,0 +1,22 @@ +## Makefile.am for sid file meta info plugin + +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) $(taglib_includes) + +# these are the headers for your project +noinst_HEADERS = tdefile_sid.h + +kde_module_LTLIBRARIES = tdefile_sid.la + +tdefile_sid_la_SOURCES = tdefile_sid.cpp +tdefile_sid_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -module $(KDE_PLUGIN) +tdefile_sid_la_LIBADD = $(LIB_KIO) + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) tdefile_sid.cpp -o $(podir)/tdefile_sid.pot + +services_DATA = tdefile_sid.desktop +servicesdir = $(kde_servicesdir) diff --git a/tdefile-plugins/sid/tdefile_sid.cpp b/tdefile-plugins/sid/tdefile_sid.cpp new file mode 100644 index 00000000..543d5b87 --- /dev/null +++ b/tdefile-plugins/sid/tdefile_sid.cpp @@ -0,0 +1,227 @@ +/* This file is part of the KDE project + * Copyright (C) 2003 Rolf Magnus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "tdefile_sid.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +typedef KGenericFactory SidFactory; + +K_EXPORT_COMPONENT_FACTORY(tdefile_sid, SidFactory("tdefile_sid")) + +KSidPlugin::KSidPlugin(TQObject *parent, const char *name, + const TQStringList &args) + + : KFilePlugin(parent, name, args) +{ + kdDebug(7034) << "sid plugin\n"; + + KFileMimeTypeInfo* info = addMimeTypeInfo("audio/prs.sid"); + + KFileMimeTypeInfo::GroupInfo* group = 0L; + + // General group + group = addGroupInfo(info, "General", i18n("General")); + + KFileMimeTypeInfo::ItemInfo* item; + + item = addItemInfo(group, "Title", i18n("Title"), TQVariant::String); + setAttributes(item, KFileMimeTypeInfo::Modifiable); + setHint(item, KFileMimeTypeInfo::Name); + + item = addItemInfo(group, "Artist", i18n("Artist"), TQVariant::String); + setAttributes(item, KFileMimeTypeInfo::Modifiable); + setHint(item, KFileMimeTypeInfo::Author); + + item = addItemInfo(group, "Copyright", i18n("Copyright"), TQVariant::String); + setAttributes(item, KFileMimeTypeInfo::Modifiable); + setHint(item, KFileMimeTypeInfo::Description); + + // technical group + group = addGroupInfo(info, "Technical", i18n("Technical Details")); + + item = addItemInfo(group, "Version", i18n("Version"), TQVariant::Int); + setPrefix(item, i18n("PSID v")); + + addItemInfo(group, "Number of Songs", i18n("Number of Songs"), TQVariant::Int); + item = addItemInfo(group, "Start Song", i18n("Start Song"), TQVariant::Int); +} + +bool KSidPlugin::readInfo(KFileMetaInfo& info, uint /*what*/) +{ + if ( info.path().isEmpty() ) // remote file + return false; + TQFile file(info.path()); + if ( !file.open(IO_ReadOnly) ) + return false; + + int version; + int num_songs; + int start_song; + TQString name; + TQString artist; + TQString copyright; + + char buf[64] = { 0 }; + + if (4 != file.readBlock(buf, 4)) + return false; + if (strncmp(buf, "PSID", 4)) + return false; + + //read version + int ch; + if (0 > (ch = file.getch())) + return false; + version = ch << 8; + if (0 > (ch = file.getch())) + return false; + version+= ch; + + //read number of songs + file.at(0xE); + if (0 > (ch = file.getch())) + return false; + num_songs = ch << 8; + if (0 > (ch = file.getch())) + return false; + num_songs += ch; + + //start song + if (0 > (ch = file.getch())) + return false; + start_song = ch << 8; + if (0 > (ch = file.getch())) + return false; + start_song += ch; + + //name + file.at(0x16); + if (32 != file.readBlock(buf, 32)) + return false; + name = buf; + + //artist + if (32 != file.readBlock(buf, 32)) + return false; + artist = buf; + + //copyright + if (32 != file.readBlock(buf, 32)) + return false; + copyright = buf; + + TQString TODO("TODO"); + kdDebug(7034) << "sid plugin readInfo\n"; + + KFileMetaInfoGroup general = appendGroup(info, "General"); + + appendItem(general, "Title", name); + appendItem(general, "Artist", artist); + appendItem(general, "Copyright", copyright); + + KFileMetaInfoGroup tech = appendGroup(info, "Technical"); + + appendItem(tech, "Version", version); + appendItem(tech, "Number of Songs", num_songs); + appendItem(tech, "Start Song", start_song); + + kdDebug(7034) << "reading finished\n"; + return true; +} + +bool KSidPlugin::writeInfo(const KFileMetaInfo& info) const +{ + kdDebug(7034) << k_funcinfo << endl; + + char name[32] = {0}; + char artist[32] = {0}; + char copyright[32] = {0}; + + int file = 0; + TQString s; + + KFileMetaInfoGroup group = info.group("General"); + if (!group.isValid()) + goto failure; + + s = group.item("Title").value().toString(); + if (s.isNull()) goto failure; + strncpy(name, s.local8Bit(), 31); + + s = group.item("Artist").value().toString(); + if (s.isNull()) goto failure; + strncpy(artist, s.local8Bit(), 31); + + s = group.item("Copyright").value().toString(); + if (s.isNull()) goto failure; + strncpy(copyright, s.local8Bit(), 31); + + kdDebug(7034) << "Opening sid file " << info.path() << endl; + file = ::open(TQFile::encodeName(info.path()), O_WRONLY); + //name + if (-1 == ::lseek(file, 0x16, SEEK_SET)) + goto failure; + if (32 != ::write(file, name, 32)) + goto failure; + + //artist + if (32 != ::write(file, artist, 32)) + goto failure; + + //copyright + if (32 != write(file, copyright, 32)) + goto failure; + + close(file); + return true; + +failure: + if (file) close(file); + kdDebug(7034) << "something went wrong writing to sid file\n"; + return false; +} + +TQValidator* +KSidPlugin::createValidator(const TQString& /*mimetype*/, const TQString& group, + const TQString& /*key*/, TQObject* parent, + const char* name) const +{ + kdDebug(7034) << k_funcinfo << endl; + // all items in "General" group are strings of max length 31 + if (group == "General") + return new TQRegExpValidator(TQRegExp(".{,31}"), parent, name); + // all others are read-only + return 0; +} + + + +#include "tdefile_sid.moc" diff --git a/tdefile-plugins/sid/tdefile_sid.desktop b/tdefile-plugins/sid/tdefile_sid.desktop new file mode 100644 index 00000000..117f2905 --- /dev/null +++ b/tdefile-plugins/sid/tdefile_sid.desktop @@ -0,0 +1,60 @@ +[Desktop Entry] +Type=Service +Name=SID Info +Name[bg]=Информация за SID +Name[br]=Titouroù SID +Name[bs]=SID informacije +Name[ca]=Informació SID +Name[cs]=SID info +Name[cy]=Gwybodaeth SID +Name[da]=SID-info +Name[de]=SID-Info +Name[el]=Πληροφορίες SID +Name[eo]=SID-informo +Name[es]=Info SID +Name[et]=SID info +Name[eu]=SID informazioa +Name[fa]=اطلاعات SID +Name[fi]=SID-tiedot +Name[fr]=Informations SID +Name[ga]=Eolas faoi SID +Name[gl]=Información SID +Name[he]=מידע SID +Name[hu]=SID-jellemzők +Name[is]=SID upplýsingar +Name[it]=Informazioni SID +Name[ja]=SID 情報 +Name[kk]=SID мәліметі +Name[km]=ព័ត៌មាន SID +Name[ko]=SID 정보 +Name[lt]=SID Informacija +Name[mk]=SID информации +Name[nb]=SID-info +Name[nds]=SID-Info +Name[ne]=एसआईडी सूचना +Name[nl]=SID-informatie +Name[nn]=SID-info +Name[pa]=SID ਜਾਣਕਾਰੀ +Name[pl]=Informacja CD +Name[pt]=Informação do SID +Name[pt_BR]=Informação sobre SID +Name[ro]=Informaţii SID +Name[ru]=Сведения о SID +Name[sk]=SID info +Name[sl]=Podatki o SID +Name[sr]=Информације о SID-у +Name[sr@Latn]=Informacije o SID-u +Name[sv]=SID-information +Name[ta]=SID தகவல் +Name[tg]=SID Ахборот +Name[th]=ข้อมูล SID +Name[tr]=SID Bilgisi +Name[uk]=Інформація по SID +Name[zh_CN]=SID 信息 +Name[zh_HK]=SID 資訊 +Name[zh_TW]=SID 資訊 +ServiceTypes=KFilePlugin +X-TDE-Library=tdefile_sid +MimeType=audio/prs.sid +PreferredGroups=General,Technical +PreferredItems=Title,Artist,Copyright,Number of Songs,Start Song,Version diff --git a/tdefile-plugins/sid/tdefile_sid.h b/tdefile-plugins/sid/tdefile_sid.h new file mode 100644 index 00000000..ba9931f7 --- /dev/null +++ b/tdefile-plugins/sid/tdefile_sid.h @@ -0,0 +1,43 @@ +/* This file is part of the KDE project + * Copyright (C) 2003 Rolf Magnus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $Id$ + */ + +#ifndef KFILE_SID_H +#define KFILE_SID_H + +#include + +class TQStringList; + +class KSidPlugin: public KFilePlugin +{ + Q_OBJECT + + +public: + KSidPlugin(TQObject *parent, const char *name, const TQStringList& args); + + virtual bool readInfo(KFileMetaInfo& info, uint what); + virtual bool writeInfo(const KFileMetaInfo& info) const; + TQValidator* createValidator(const TQString& mimetype, const TQString& group, + const TQString& key, TQObject* parent, + const char* name) const; +}; + +#endif -- cgit v1.2.1