diff options
Diffstat (limited to 'kfile-plugins/lnk')
-rw-r--r-- | kfile-plugins/lnk/Makefile.am | 34 | ||||
-rw-r--r-- | kfile-plugins/lnk/README | 29 | ||||
-rw-r--r-- | kfile-plugins/lnk/kfile_lnk.cpp | 93 | ||||
-rw-r--r-- | kfile-plugins/lnk/kfile_lnk.desktop | 62 | ||||
-rw-r--r-- | kfile-plugins/lnk/kfile_lnk.h | 46 | ||||
-rw-r--r-- | kfile-plugins/lnk/lnkforward.cpp | 130 | ||||
-rw-r--r-- | kfile-plugins/lnk/lnkforward.desktop | 114 | ||||
-rw-r--r-- | kfile-plugins/lnk/lnkforward.h | 42 | ||||
-rw-r--r-- | kfile-plugins/lnk/read_lnk.cpp | 227 | ||||
-rw-r--r-- | kfile-plugins/lnk/read_lnk.h | 46 | ||||
-rw-r--r-- | kfile-plugins/lnk/x-win-lnk.desktop | 61 |
11 files changed, 884 insertions, 0 deletions
diff --git a/kfile-plugins/lnk/Makefile.am b/kfile-plugins/lnk/Makefile.am new file mode 100644 index 0000000..9d97978 --- /dev/null +++ b/kfile-plugins/lnk/Makefile.am @@ -0,0 +1,34 @@ +## Makefile.am for lnk file meta info plugin + +INCLUDES = $(all_includes) + +bin_PROGRAMS = lnkforward + +lnkforward_SOURCES = lnkforward.cpp +lnkforward_LDADD = $(LIB_KDECORE) $(LIB_KIO) +lnkforward_LDFLAGS = $(all_libraries) $(KDE_RPATH) +lnkforward_METASOURCES = lnkforward.moc + +lnkforward_DATA = lnkforward.desktop +lnkforwarddir = $(kde_appsdir)/.hidden + +# these are the headers for your project +noinst_HEADERS = kfile_lnk.h read_lnk.h lnkforward.h + +kde_module_LTLIBRARIES = kfile_lnk.la + +kfile_lnk_la_SOURCES = kfile_lnk.cpp read_lnk.cpp +kfile_lnk_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kfile_lnk_la_LIBADD = $(LIB_KIO) +kfile_lnk_la_METASOURCES = kfile_lnk.moc + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +kde_services_DATA = kfile_lnk.desktop + +mime_DATA = x-win-lnk.desktop +mimedir = $(kde_mimedir)/application + +messages: + $(XGETTEXT) *.cpp -o $(podir)/kfile_lnk.pot diff --git a/kfile-plugins/lnk/README b/kfile-plugins/lnk/README new file mode 100644 index 0000000..a61c473 --- /dev/null +++ b/kfile-plugins/lnk/README @@ -0,0 +1,29 @@ +29.May 2004, Martin Koller, m.koller@surfeu.at + +This package shall help a better integration of KDE/Linux into a Windows environment +by providing tools to work with Windows .lnk files + +This package contains 2 tools: + +- a KFile plugin, kfile_lnk, which gives metadata information for a .lnk file (where does it point to) + +- a small tool, lnkforward, to start an associated application for which the path is in a .lnk file + (e.g. when you double-click a file in konqueror) + +The .lnk file is registered as MIME type application/x-win-lnk + +If you have a dual-boot machine, and you have your Windows partition(s) mounted, +then you should adapt where konqi can find the corresponding C:, D: or other drives. +For this you have to adapt the used commandline arguments for lnkforward, which you +can do in konqis file-associations for the MIME type application/x-win-lnk + +The lnkforward tool shall get a commandline option like this: + +-map C=/mnt/winC -map D=/mnt/winD + +NOTE: both tools work with .lnk files which are either readable via the local filesystem +(smbfs mounted filesystems) or also via URLs on the network, e.g. smb://something + +Have fun. + +Martin diff --git a/kfile-plugins/lnk/kfile_lnk.cpp b/kfile-plugins/lnk/kfile_lnk.cpp new file mode 100644 index 0000000..6d8ea94 --- /dev/null +++ b/kfile-plugins/lnk/kfile_lnk.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +// format of a .lnk file retrieved from: +// http://www.i2s-lab.com/Papers/The_Windows_Shortcut_File_Format.pdf + +#include <config.h> +#include "kfile_lnk.h" +#include "read_lnk.h" + +#include <kgenericfactory.h> + +//-------------------------------------------------------------------------------- + +typedef KGenericFactory<lnkPlugin> lnkFactory; + +K_EXPORT_COMPONENT_FACTORY(kfile_lnk, lnkFactory( "kfile_lnk" )) + +//-------------------------------------------------------------------------------- + +lnkPlugin::lnkPlugin(QObject *parent, const char *name, + const QStringList &args) + : KFilePlugin(parent, name, args) +{ + KFileMimeTypeInfo* info = addMimeTypeInfo( "application/x-win-lnk" ); + + // our new group + KFileMimeTypeInfo::GroupInfo* group = 0; + group = addGroupInfo(info, "lnkInfo", i18n("Windows Link File Information")); + + KFileMimeTypeInfo::ItemInfo* item; + + // our new items in the group + item = addItemInfo(group, "TargetSize", i18n("Size of Target"), QVariant::Int); + setUnit(item, KFileMimeTypeInfo::Bytes); + + addItemInfo(group, "Where", i18n("Location"), QVariant::String); + addItemInfo(group, "PointsTo", i18n("Points To"), QVariant::String); + addItemInfo(group, "Description", i18n("Description"), QVariant::String); +} + +//-------------------------------------------------------------------------------- + +bool lnkPlugin::readInfo( KFileMetaInfo& info, uint /*what*/) +{ + KFileMetaInfoGroup group = appendGroup(info, "lnkInfo"); + + LNKInfo lnkInfo; + bool ret = readLNK(info.url(), lnkInfo); + + if ( ! ret ) return false; + + if ( ! lnkInfo.isDirectory ) // not a directory + appendItem(group, "TargetSize", lnkInfo.fileSize); + + if ( ! lnkInfo.isFileOrDir ) // points to something != file or directory + return false; + + if ( ! lnkInfo.isNetworkPath ) + { + appendItem(group, "Where", i18n("on Windows disk: %1").arg(lnkInfo.volumeName)); // volume label + appendItem(group, "PointsTo", QString("%1%2").arg(lnkInfo.driveName).arg(lnkInfo.path)); + } + else + { + appendItem(group, "Where", i18n("on network share")); + appendItem(group, "PointsTo", lnkInfo.path); + } + + if ( ! lnkInfo.description.isNull() ) // has description string + appendItem(group, "Description", lnkInfo.description); + + return true; +} + +#include "kfile_lnk.moc" diff --git a/kfile-plugins/lnk/kfile_lnk.desktop b/kfile-plugins/lnk/kfile_lnk.desktop new file mode 100644 index 0000000..bad39b3 --- /dev/null +++ b/kfile-plugins/lnk/kfile_lnk.desktop @@ -0,0 +1,62 @@ +[Desktop Entry] +Type=Service +Name=Windows lnk File Info +Name[bg]=Информация за файл връзка на Windows +Name[br]=Titouroù diwar-benn ar restr Windows lnk +Name[bs]=Windows lnk informacije o datoteci +Name[ca]=Informació dels fitxers lnk de Windows +Name[cs]=Informace o Windows lnk souboru +Name[da]=Information om Windows lnk-fil +Name[de]=Informationen zur Windows-Verknüpfungsdatei +Name[el]=Πληροφορίες αρχείου lnk των Windows +Name[eo]=Vindoza lnk dosiera informo +Name[es]=Información del archivo lnk de Windows +Name[et]=Windowsi .lnk-faili info +Name[eu]=Windowsen Ink fitxategiaren informazioa +Name[fa]=اطلاعات پروندۀ lnk ویندوز +Name[fi]=Windows lnk-tiedoston tiedot +Name[fr]=Informations sur le fichier « .lnk » Windows +Name[fy]=Windows lnk-triemynformaasje +Name[ga]=Eolas faoin Chomhad lnk Windows +Name[gl]=Información de Ficheiros lnk de Windows +Name[he]= מידע קובץ lnk של Windows +Name[hi]=विंडो लिंक फ़ाइल जानकारी +Name[hr]=Podaci Windows prečaca +Name[hu]=Információ Windows-os Lnk-fájlokról +Name[is]=Upplýsingar um Windows lnk-skrá +Name[it]=File di informazioni Windows lnk +Name[ja]=Windows lnk ファイル情報 +Name[ka]=Windows lnk ფაილის ინფორმაცია +Name[kk]=Windows жарлық файлдың мәліметі +Name[km]=ព័ត៌មានឯកសារបង្អួចឯកសារ lnk +Name[lt]=Windows lnk bylos informacija +Name[mk]=Информации за Windows Ink-датотека +Name[ms]=Maklumat Fail Dakwat Tetingkap +Name[nb]=Informasjon om Windows lnk-fil +Name[nds]=Informatschonen över de Windows-Linkdatei (.lnk) +Name[ne]=विन्डोज lnk फाइल सूचना +Name[nl]=Windows lnk-bestandsinformatie +Name[nn]=Informasjon om Windows lnk-fil +Name[pa]=Windows lnk ਫਾਇਲ ਜਾਣਕਾਰੀ +Name[pl]=Informacja plików lnk systemu Windows +Name[pt]=Informação do Ficheiro '.lnk' do Windows +Name[pt_BR]=Informações de Arquivo do Windows +Name[ru]=Сведения о ярлыке Windows +Name[sk]=Informácie o súbore Windows lnk +Name[sl]=Informacija o datoteki Windows .lnk +Name[sr]=Подаци о Windows-овом .lnk фајлу +Name[sr@Latn]=Podaci o Windows-ovom .lnk fajlu +Name[sv]=Information om Windows länkfil +Name[ta]=விண்டோஸ் இங்க் கோப்பு தகவல் +Name[tg]=Маълумотҳо дар бораи ярлиқи Windows +Name[tr]=Windows lnk Dosya Bilgisi +Name[uk]=Інформація про файл lnk для Windows +Name[uz]=Windows lnk fayli haqida maʼlumot +Name[uz@cyrillic]=Windows lnk файли ҳақида маълумот +Name[vi]=Thông tin tập tin Ink Windows +Name[zh_CN]=Windows lnk 文件信息 +Name[zh_TW]=Windows lnk 檔資訊 +ServiceTypes=KFilePlugin +X-KDE-Library=kfile_lnk +MimeType=application/x-win-lnk +PreferredItems=PointsTo,Where,TargetSize,Description diff --git a/kfile-plugins/lnk/kfile_lnk.h b/kfile-plugins/lnk/kfile_lnk.h new file mode 100644 index 0000000..3ee4ae8 --- /dev/null +++ b/kfile-plugins/lnk/kfile_lnk.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This plugin provides information about the content of a * + * M$-Windoze .lnk file, which is useful if you work in a mixed * + * Linux/Windoze environment. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef __KFILE_LNK_H__ +#define __KFILE_LNK_H__ + +/** + * Note: For further information look into <$KDEDIR/include/kfilemetainfo.h> + */ +#include <kfilemetainfo.h> + +class QStringList; + +class lnkPlugin: public KFilePlugin +{ + Q_OBJECT + +public: + lnkPlugin( QObject *parent, const char *name, const QStringList& args ); + + virtual bool readInfo( KFileMetaInfo& info, uint what); +}; + +#endif // __KFILE_LNK_H__ + diff --git a/kfile-plugins/lnk/lnkforward.cpp b/kfile-plugins/lnk/lnkforward.cpp new file mode 100644 index 0000000..a79a7db --- /dev/null +++ b/kfile-plugins/lnk/lnkforward.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This helper app runs the associated action for a linked file inside a * + * M$-Windoze .lnk file, which is useful if you work in a mixed * + * Linux/Windoze environment. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "read_lnk.cpp" +#include "lnkforward.h" + +#include <stdlib.h> + +#include <klocale.h> +#include <krun.h> +#include <kdebug.h> + +//-------------------------------------------------------------------------------- + +static const char appName[] = "lnkforward"; +static const char programName[] = I18N_NOOP("lnkforward"); + +static const char description[] = I18N_NOOP("KDE tool for opening URLs given in a Windows .lnk file"); + +static const char version[] = "1.0"; + +static const KCmdLineOptions options[] = +{ + { "map <drive=path>", I18N_NOOP("Map a Windows drive to a local mountpoint, e.g. \"C=/mnt/windows\"" + "\nThis option can be given multiple times"), 0}, + { "+URL", I18N_NOOP("Windows .lnk file to open"), 0}, + KCmdLineLastOption +}; + +//-------------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + KCmdLineArgs::init(argc, argv, appName, programName, description, version, false); + + KCmdLineArgs::addCmdLineOptions(options); + + LNKForwarder app; + + return app.run(KCmdLineArgs::parsedArgs()); +} + +//-------------------------------------------------------------------------------- + +int LNKForwarder::run(KCmdLineArgs *args) +{ + if ( args->count() == 0 ) return 1; + + LNKInfo info; + + bool ret = readLNK(args->arg(0), info); + if ( ! ret ) return 1; + + info.path.replace(QChar('\\'), QChar('/')); + + QString path; + + if ( info.isNetworkPath ) + { + path = "smb:" + info.path; + } + else + { + if ( info.driveName.isNull() ) return 1; // can this ever happen ? + + QCStringList map = args->getOptionList("map"); + bool found = false; + + for (unsigned int i = 0; i < map.count(); i++) + { + if ( map[i].lower()[0] == info.driveName.lower()[0] ) + { + if ( map[i].length() < 3 ) + { + return 1; + } + path = map[i].mid(2); // skip e.g. "C=" + found = true; + break; + } + } + + if ( !found ) return 1; // no mapped drive found + + path += '/'; // make sure that the dir ends with / + path += info.path; + } + + kdDebug(7034) << "running:" << path << endl; + KRun * run = new KRun(path); + QObject::connect(run, SIGNAL(finished()), this, SLOT(delayedQuit())); + QObject::connect(run, SIGNAL(error()), this, SLOT(delayedQuit())); + + return exec(); +} + +//-------------------------------------------------------------------------------- +// copied from kfmclient.cc + +void LNKForwarder::delayedQuit() +{ + // Quit in 2 seconds. This leaves time for KRun to pop up + // "app not found" in KProcessRunner, if that was the case. + QTimer::singleShot(2000, this, SLOT(deref())); +} + +//-------------------------------------------------------------------------------- + +#include "lnkforward.moc" diff --git a/kfile-plugins/lnk/lnkforward.desktop b/kfile-plugins/lnk/lnkforward.desktop new file mode 100644 index 0000000..b7e2303 --- /dev/null +++ b/kfile-plugins/lnk/lnkforward.desktop @@ -0,0 +1,114 @@ +[Desktop Entry] +Type=Application +Comment=Start link given in Windows .lnk file +Comment[bg]=Стартиране на файл връзка на Windows +Comment[bs]=Pokreni link dat u Windows .lnk datoteci +Comment[ca]=Inicia l'enllaç donat pel fitxer .lnk de Windows +Comment[cs]=Spustit odkaz daný v .lnk souboru +Comment[da]=Start link givet i Windows .lnk-fil +Comment[de]=Ausführen der Verknüpfung aus einer Windows-Verknüpfungsdatei +Comment[el]=Εκκίνηση του δεσμού που δίνεται στο αρχείο .lnk των Windows +Comment[es]=Inicia el enlace que se encuentra en el archivo .lnk de Windows +Comment[et]=Käivitab Windowsi .lnk-failis antud viida +Comment[eu]=Hasieratu Windowsen .Ink fitxategiaren esteka +Comment[fa]=آغاز پیوند دادهشده در پروندۀ .lnk ویندوز +Comment[fi]=Käynnistä Windows .lnk-tiedostossa annettu linkki +Comment[fr]=Lancer le lien issu d'un fichier « .lnk » Windows +Comment[fy]=Folget keppeling yn de Windows .lnk-triem +Comment[ga]=Nasc tosaigh ón chomhad .lnk Windows +Comment[gl]=Iniciar o enlace dado nun ficheiro .lnk de Windows +Comment[he]=התחל קיצור בקובץ lnk של Windows +Comment[hi]=विंडोज़ के .lnk फ़ाइल में स्टार्ट लिंक दिया गया है +Comment[hr]=Pokretanje veze iz Windows datoteke .lnk +Comment[hu]=Link megnyitása Windows-os Lnk-fájl alapján +Comment[is]=Ræsa tengil í Windows lnk skrá +Comment[it]=Collegamento iniziale dato nel file .lnk di Windows +Comment[ja]=Windows の .lnk ファイルのリンクを開始 +Comment[ka]=Windows .lnk ფაილში მოცემული ბმულის გაშვება +Comment[kk]=Windows .lnk файл сілтегенің жегу +Comment[km]=ចាប់ផ្ដើមតំណដែលបានផ្ដល់ក្នុងបង្អួចឯកសារ .lnk +Comment[lt]=Atverti nuorodą, nurodytą Windows .lnk byloje +Comment[mk]=Ја стартува врската дадена во Windows .lnk-датотека +Comment[ms]=Mulakan pautan yang diberikan dalam Tetingkap. Fail dakwat +Comment[nb]=Start lenka oppgitt i en Windows .lnk-fil +Comment[nds]=Den Link ut Windows-Linkdatei utföhren +Comment[ne]=विन्डोज .lnk फाइलमा दिएको लिङ्क सुरुआत गर्नुहोस् +Comment[nl]=Volgt koppeling in het Windows .lnk-bestand +Comment[nn]=Start lenkja oppgjeve i ei Windows .lnk-fil +Comment[pl]=Uruchamia odnośnik znajdujący się w plikach .lnk systemu Windows +Comment[pt]=Iniciar a ligação definida pelo ficheiro .lnk do Windows +Comment[pt_BR]=Inicia um link fornecido de um arquivo .lnk do Windows +Comment[ru]=Перейти по ссылке из ярлыка Windows (.lnk) +Comment[sk]=Spustenie zadaného odkazu v súbore Windows .lnk +Comment[sl]=Zaženi povezavo, dano v datoteki Windows .lnk +Comment[sr]=Покреће везу дату у Windows-овом .lnk фајлу +Comment[sr@Latn]=Pokreće vezu datu u Windows-ovom .lnk fajlu +Comment[sv]=Starta länk given i en Windows länkfil +Comment[ta]=விண்டோஸ் .lnk fileசில் கொடுக்கப்பட்டதற்கு இணைப்பை துவக்கவும் +Comment[tg]=Гузаштан бо истинод аз ярлиқи Windows (.lnk) +Comment[tr]=Windows .lnk dosyasında verilen başlangıç kısayolu +Comment[uk]=Перейти по посиланню з файла .lnk для Windows +Comment[uz]=Windows .lnk faylida koʻrsatilgan bogʻga oʻtish +Comment[uz@cyrillic]=Windows .lnk файлида кўрсатилган боғга ўтиш +Comment[vi]=Liên kết bắt đầu được ghi trong tập tin .Ink của Windows +Comment[zh_CN]=启动 Windows .lnk 文件中给出的链接 +Comment[zh_TW]=連結 Windows .lnk 檔中指定的網址 +Exec=lnkforward -map C=/mnt/winc +MimeType=application/x-win-lnk +Name=Windows lnk File Forwarder +Name[bg]=Препращане за файл връзка на Windows +Name[bs]=Windows lnk datoteka preusmjerivač +Name[ca]=Enviador de fitxers Windows Ink +Name[cs]=Informace o odkazech +Name[da]=Videresender af Windows ink-fil +Name[de]=Weiterleitung für Windows-Verknüpfungsdateien +Name[el]=Προωθητής αρχείου lnk των Windows +Name[eo]=Vindoza lnk dosiera antaŭigilo +Name[es]=Expedidor de archivos lnk de Windows +Name[et]=Windowsi .lnk-faili käivitaja +Name[eu]=Windowsen Ink fitxategiaren berbidaltzailea +Name[fa]=پیشسوی پروندۀ lnk ویندوز +Name[fi]=Windows lnk-tiedoston edelleenohjaus +Name[fr]=Transmetteur de fichiers « .lnk » Windows +Name[fy]=Windows lnk-triemferwizing +Name[gl]=Reenvio através de Ficheiros Windows lnk +Name[he]=קיצור דרך של Windows +Name[hi]=विंडोज़ लिंक फ़ाइल फॉर्वर्डर +Name[hr]=Prosljeđivanje Windows prečaca +Name[hu]=Windows-os Lnk-fájl továbbítása +Name[is]=Windows lnk skráarframsendir +Name[it]=File lnk di windows con funzione forwarder +Name[ja]=Windows lnk ファイルフォワーダ +Name[ka]=Windows lnk ფაილის გადამცემი +Name[kk]=Windows жарлығының сілтемесіне өту +Name[km]=កម្មវិធីបញ្ជូនបន្តបង្អួចឯកសារ lnk +Name[lt]=Windows lnk bylų nuorodos +Name[mk]=Пренасочувач на Windows lnk-датотеки +Name[ms]=Pemaju Fail Dakwat Tetingkap +Name[nb]=Videresender Windows lnk-fil +Name[nds]=Wiederledden för Windows-Linkdateien +Name[ne]=विन्डोज lnk फाइल अगाडि बढाउने +Name[nl]=Windows lnk-bestandsverwijzing +Name[nn]=Vidaresender Windows lnk-fil +Name[pa]=Windows lnk ਫਾਇਲ ਫਾਰਵਰਡਰ +Name[pl]=Interpretacja plików lnk systemu Windows +Name[pt]=Encaminhamento de Ficheiros do Windows +Name[pt_BR]=Informações de Aplicativos do Windows +Name[ru]=Перенаправление по ярлыку Windows +Name[sk]=Presmerovač súborov Windows lnk +Name[sl]=Posredovalnik za bližnjice v Windows +Name[sr]=Прослеђивач Windows-ових .lnk фајлова +Name[sr@Latn]=Prosleđivač Windows-ovih .lnk fajlova +Name[sv]=Följ Windows länkfil +Name[ta]=விண்டோஸ் மை கோப்பு திருப்புபவன் +Name[tg]=Равона бо ярлиқи Windows +Name[tr]=Windows lnk Dosya Yönlendirici +Name[uk]=Спрямування за файлом lnk для Windows +Name[vi]=Bộ chuyển tiếp tập tin Ink Windows +Name[zh_CN]=Windows lnk 文件转发器 +Name[zh_TW]=Windows lnk 檔轉載 +StartupNotify=false +Terminal=false +X-KDE-SubstituteUID=false +Icon=exec_wine +NoDisplay=true diff --git a/kfile-plugins/lnk/lnkforward.h b/kfile-plugins/lnk/lnkforward.h new file mode 100644 index 0000000..8810902 --- /dev/null +++ b/kfile-plugins/lnk/lnkforward.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This helper app runs the associated action for a linked file inside a * + * M$-Windoze .lnk file, which is useful if you work in a mixed * + * Linux/Windoze environment. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <kapplication.h> +#include <kcmdlineargs.h> + +#ifndef _LNKFORWARDER_H_ +#define _LNKFORWARDER_H_ + +class LNKForwarder : public KApplication +{ + Q_OBJECT + + public: + int run(KCmdLineArgs *args); + + protected slots: + void delayedQuit(); +}; + +#endif diff --git a/kfile-plugins/lnk/read_lnk.cpp b/kfile-plugins/lnk/read_lnk.cpp new file mode 100644 index 0000000..2d627fb --- /dev/null +++ b/kfile-plugins/lnk/read_lnk.cpp @@ -0,0 +1,227 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This function reads the content of a M$-Windoze .lnk file * + * and returns data in the given structure. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "read_lnk.h" +#include <stdio.h> +#include <kdebug.h> +#include <kio/netaccess.h> + +//-------------------------------------------------------------------------------- + +//TODO: little/big endian problem ? +struct LNKHeader +{ + char magic[4]; + char GUID[16]; + Q_UINT32 flags; + Q_UINT32 attributes; + char time1[8]; + char time2[8]; + char time3[8]; + Q_UINT32 length; + Q_UINT32 iconNum; + Q_UINT32 showWnd; + Q_UINT32 hotKey; + char filler[8]; +}; + +struct LNKFileLocation +{ + Q_UINT32 totalLen; + Q_UINT32 ptr; + Q_UINT32 flags; + Q_UINT32 localVolume; + Q_UINT32 basePath; + Q_UINT32 netVolume; + Q_UINT32 pathname; +}; + +//-------------------------------------------------------------------------------- + +bool readLNK(const KURL &url, LNKInfo &info) +{ + const char* lnkFile = 0; + + QString tempFile; + if ( KIO::NetAccess::download(url, tempFile, 0) ) + lnkFile = tempFile.latin1(); + else + return false; + + kdDebug(7034) << "opening:" << lnkFile << endl; + FILE *fd = fopen(lnkFile, "rb"); + if ( !fd ) + { + kdWarning(7034) << "could not open file " << lnkFile << endl; + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + LNKHeader header; + + if ( fread(&header, sizeof(header), 1, fd) != 1 ) + { + kdWarning(7034) << "wrong header size" << endl; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + if ( memcmp(header.magic, "L\0\0\0", 4) != 0 ) + { + kdWarning(7034) << "wrong magic in header" << endl; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + if ( header.flags & 0x1 ) // the shell item id list is present + { + Q_UINT16 len; + + // skip that list + if ( (fread(&len, sizeof(len), 1, fd) != 1) || (fseek(fd, len, SEEK_CUR) != 0) ) + { + kdWarning(7034) << "could not read shell item id list" << endl; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + } + + info.isDirectory = (header.attributes & 0x10); + + if ( ! info.isDirectory ) // not a directory + info.fileSize = header.length; + + info.isFileOrDir = (header.flags & 0x2); // points to file or directory + + if ( info.isFileOrDir ) + { + LNKFileLocation loc; + + if ( fread(&loc, sizeof(loc), 1, fd) != 1 ) + { + kdWarning(7034) << "could not read file localtion table" << endl; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + // limit the following "new", because the size to allocate is in the file + // which can easily be manipulted to contain a huge number and lead to a crash + if ( (loc.totalLen <= sizeof(loc)) || (loc.totalLen > 4096) ) // 4096 is just an arbitrary number I think shall be enough + { + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + size_t size = loc.totalLen - sizeof(loc); + char *data = new char[size]; + char *start = data - sizeof(loc); + + if ( fread(data, size, 1, fd) != 1 ) + { + kdWarning(7034) << "could not read pathes data" << endl; + delete [] data; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + info.isNetworkPath = !(loc.flags & 0x1); + + if ( !info.isNetworkPath ) + { + info.volumeName = (start + loc.localVolume + 0x10); // volume label + + info.path = QString::null; + + if ( *(start + loc.basePath) ) + { + // Don't put any more than "X:" into info.driveName. + info.driveName = *(start + loc.basePath); + info.driveName += ':'; + + // If we in fact do have more than just "X:", store any additional + // path information separately in info.path. + if ( *(start + loc.basePath + 1) == ':' && + *(start + loc.basePath + 2) != 0) + info.path = (start + loc.basePath + 2); + } + + if ( *(start + loc.pathname) != 0 ) + { + if ( info.path.isNull() ) + info.path = (start + loc.pathname); + else + info.path = info.path + "\\" + (start + loc.pathname); + } + } + else // network path + { + info.path = QString("%1\\%2") + .arg(start + loc.netVolume + 0x14) // network share name + .arg(start + loc.pathname); + } + + delete [] data; + data = 0; + + if ( header.flags & 0x4 ) // has description string + { + Q_UINT16 len; + + if ( fread(&len, sizeof(len), 1, fd) != 1 ) + { + kdWarning(7034) << "could not read description string length" << endl; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + data = new char[len+1]; // this can never be > 65K, so its OK to not check the size + + if ( fread(data, len, 1, fd) != 1 ) + { + kdWarning(7034) << "could not read description string" << endl; + delete [] data; + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + return false; + } + + data[len] = 0; // nullbyte seems to miss + + info.description = data; + + delete [] data; + } + } + + fclose(fd); + KIO::NetAccess::removeTempFile(tempFile); + + return true; +} diff --git a/kfile-plugins/lnk/read_lnk.h b/kfile-plugins/lnk/read_lnk.h new file mode 100644 index 0000000..da947a1 --- /dev/null +++ b/kfile-plugins/lnk/read_lnk.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * m.koller@surfeu.at * + * * + * This function reads the content of a M$-Windoze .lnk file * + * and returns data in the given structure. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef _READ_LNK_H_ +#define _READ_LNK_H_ + +#include <qstring.h> +class KURL; + +struct LNKInfo +{ + LNKInfo() : fileSize(0), isNetworkPath(false), isDirectory(false), isFileOrDir(false) {} + + Q_UINT32 fileSize; + bool isNetworkPath; + bool isDirectory; + bool isFileOrDir; + QString volumeName; + QString driveName; + QString path; + QString description; +}; + +bool readLNK(const KURL &url, LNKInfo &info); + +#endif diff --git a/kfile-plugins/lnk/x-win-lnk.desktop b/kfile-plugins/lnk/x-win-lnk.desktop new file mode 100644 index 0000000..18429dc --- /dev/null +++ b/kfile-plugins/lnk/x-win-lnk.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Type=MimeType +Comment=Windows Link-File +Comment[bg]=Файл връзка на Windows +Comment[bs]=Windows link datoteka +Comment[ca]=Fitxer enllaç de Windows +Comment[cs]=Soubor s odkazem Windows +Comment[da]=Windows link-fil +Comment[de]=Windows-Verknüpfungsdatei +Comment[el]=Αρχείο δεσμού των Windows +Comment[eo]=Vindoza ligdosiero +Comment[es]=Archivo de enlace de Windows +Comment[et]=Windowsi link-fail +Comment[eu]=Windowsen esteka-fitxategia +Comment[fa]=پروندۀ پیوند ویندوز +Comment[fi]=Windows linkkitiedosto +Comment[fr]=Fichier de lien de Windows +Comment[fy]=Windows snelkeppeling +Comment[ga]=Comhad Naisc Windows +Comment[gl]=Ficheiro Windows Link +Comment[he]=קיצור דרך של Windows +Comment[hi]=विंडो लिंक-फ़ाइल +Comment[hr]=Datoteka Windows prečaca +Comment[hu]=Windows-os Lnk-fájl +Comment[is]=Windows tengiskrá +Comment[it]=Windows file di link +Comment[ja]=Windows リンクファイル +Comment[ka]=Windows-ის ბმულის ფაილი +Comment[kk]=Windows сілтеме файлы +Comment[km]=បង្អួចឯកសារតំណ +Comment[lt]=Windows bylų nuorodos +Comment[mk]=Windows Link-датотека +Comment[ms]=Fail Pautan Tetingkap +Comment[nb]=Windows Link-fil +Comment[nds]=Windows-Linkdatei +Comment[ne]=विन्डोज लिङ्क- फाइल +Comment[nl]=Windows snelkoppeling +Comment[nn]=Windows lenkjefil +Comment[pa]=Windows ਸਬੰਧ-ਫਾਇਲ +Comment[pl]=Plik odnośnika Windows +Comment[pt]=Ficheiro Windows Link +Comment[pt_BR]=Arquivo Link do Windows +Comment[ru]=Ярлык Windows +Comment[sk]=Odkaz Windows +Comment[sl]=Datoteka z bližnjico v Windows +Comment[sr]=Windows-ов фајл везе +Comment[sr@Latn]=Windows-ov fajl veze +Comment[sv]=Windows länkfil +Comment[ta]=விண்டோஸ் இணைப்பு-கோப்பு +Comment[tg]=Ярлиқи Windows +Comment[tr]=Windows Kısayol Dosyası +Comment[uk]=файл посилання для Windows +Comment[uz]=Windows bogʻ fayli +Comment[uz@cyrillic]=Windows боғ файли +Comment[vi]=Tập tin liên kết Windows +Comment[zh_CN]=Windows 快捷方式文件 +Comment[zh_TW]=Windows Link 檔 +Hidden=false +Icon=exec_wine +MimeType=application/x-win-lnk +Patterns=*.lnk |