diff options
author | Timothy Pearson <[email protected]> | 2013-01-27 01:00:38 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-01-27 01:00:38 -0600 |
commit | 4bc3dcd8cbc23e1470e121e25a83d57c22e61b26 (patch) | |
tree | 7d379893635b06789888944241a976a4f2b440ab /tdefile-plugins/lnk | |
parent | 08a66075486dc740840cfb817bf0ca301c6f0385 (diff) | |
download | tdeaddons-4bc3dcd8cbc23e1470e121e25a83d57c22e61b26.tar.gz tdeaddons-4bc3dcd8cbc23e1470e121e25a83d57c22e61b26.zip |
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdefile-plugins/lnk')
-rw-r--r-- | tdefile-plugins/lnk/Makefile.am | 34 | ||||
-rw-r--r-- | tdefile-plugins/lnk/README | 29 | ||||
-rw-r--r-- | tdefile-plugins/lnk/lnkforward.cpp | 130 | ||||
-rw-r--r-- | tdefile-plugins/lnk/lnkforward.desktop | 114 | ||||
-rw-r--r-- | tdefile-plugins/lnk/lnkforward.h | 43 | ||||
-rw-r--r-- | tdefile-plugins/lnk/read_lnk.cpp | 227 | ||||
-rw-r--r-- | tdefile-plugins/lnk/read_lnk.h | 46 | ||||
-rw-r--r-- | tdefile-plugins/lnk/tdefile_lnk.cpp | 93 | ||||
-rw-r--r-- | tdefile-plugins/lnk/tdefile_lnk.desktop | 62 | ||||
-rw-r--r-- | tdefile-plugins/lnk/tdefile_lnk.h | 47 | ||||
-rw-r--r-- | tdefile-plugins/lnk/x-win-lnk.desktop | 61 |
11 files changed, 886 insertions, 0 deletions
diff --git a/tdefile-plugins/lnk/Makefile.am b/tdefile-plugins/lnk/Makefile.am new file mode 100644 index 0000000..083f9a0 --- /dev/null +++ b/tdefile-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_TDECORE) $(LIB_KIO) +lnkforward_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +lnkforward_METASOURCES = lnkforward.moc + +lnkforward_DATA = lnkforward.desktop +lnkforwarddir = $(kde_appsdir)/.hidden + +# these are the headers for your project +noinst_HEADERS = tdefile_lnk.h read_lnk.h lnkforward.h + +kde_module_LTLIBRARIES = tdefile_lnk.la + +tdefile_lnk_la_SOURCES = tdefile_lnk.cpp read_lnk.cpp +tdefile_lnk_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +tdefile_lnk_la_LIBADD = $(LIB_KIO) +tdefile_lnk_la_METASOURCES = tdefile_lnk.moc + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +kde_services_DATA = tdefile_lnk.desktop + +mime_DATA = x-win-lnk.desktop +mimedir = $(kde_mimedir)/application + +messages: + $(XGETTEXT) *.cpp -o $(podir)/tdefile_lnk.pot diff --git a/tdefile-plugins/lnk/README b/tdefile-plugins/lnk/README new file mode 100644 index 0000000..8b17918 --- /dev/null +++ b/tdefile-plugins/lnk/README @@ -0,0 +1,29 @@ +29.May 2004, Martin Koller, [email protected] + +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, tdefile_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/tdefile-plugins/lnk/lnkforward.cpp b/tdefile-plugins/lnk/lnkforward.cpp new file mode 100644 index 0000000..6161a15 --- /dev/null +++ b/tdefile-plugins/lnk/lnkforward.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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("TDE 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) +{ + TDECmdLineArgs::init(argc, argv, appName, programName, description, version, false); + + TDECmdLineArgs::addCmdLineOptions(options); + + LNKForwarder app; + + return app.run(TDECmdLineArgs::parsedArgs()); +} + +//-------------------------------------------------------------------------------- + +int LNKForwarder::run(TDECmdLineArgs *args) +{ + if ( args->count() == 0 ) return 1; + + LNKInfo info; + + bool ret = readLNK(args->arg(0), info); + if ( ! ret ) return 1; + + info.path.replace(TQChar('\\'), TQChar('/')); + + TQString 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); + TQObject::connect(run, TQT_SIGNAL(finished()), this, TQT_SLOT(delayedQuit())); + TQObject::connect(run, TQT_SIGNAL(error()), this, TQT_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 TDEProcessRunner, if that was the case. + TQTimer::singleShot(2000, this, TQT_SLOT(deref())); +} + +//-------------------------------------------------------------------------------- + +#include "lnkforward.moc" diff --git a/tdefile-plugins/lnk/lnkforward.desktop b/tdefile-plugins/lnk/lnkforward.desktop new file mode 100644 index 0000000..8897490 --- /dev/null +++ b/tdefile-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-TDE-SubstituteUID=false +Icon=exec_wine +NoDisplay=true diff --git a/tdefile-plugins/lnk/lnkforward.h b/tdefile-plugins/lnk/lnkforward.h new file mode 100644 index 0000000..14b3e76 --- /dev/null +++ b/tdefile-plugins/lnk/lnkforward.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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 TDEApplication +{ + Q_OBJECT + + + public: + int run(TDECmdLineArgs *args); + + protected slots: + void delayedQuit(); +}; + +#endif diff --git a/tdefile-plugins/lnk/read_lnk.cpp b/tdefile-plugins/lnk/read_lnk.cpp new file mode 100644 index 0000000..47ed5a5 --- /dev/null +++ b/tdefile-plugins/lnk/read_lnk.cpp @@ -0,0 +1,227 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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 <tdeio/netaccess.h> + +//-------------------------------------------------------------------------------- + +//TODO: little/big endian problem ? +struct LNKHeader +{ + char magic[4]; + char GUID[16]; + TQ_UINT32 flags; + TQ_UINT32 attributes; + char time1[8]; + char time2[8]; + char time3[8]; + TQ_UINT32 length; + TQ_UINT32 iconNum; + TQ_UINT32 showWnd; + TQ_UINT32 hotKey; + char filler[8]; +}; + +struct LNKFileLocation +{ + TQ_UINT32 totalLen; + TQ_UINT32 ptr; + TQ_UINT32 flags; + TQ_UINT32 localVolume; + TQ_UINT32 basePath; + TQ_UINT32 netVolume; + TQ_UINT32 pathname; +}; + +//-------------------------------------------------------------------------------- + +bool readLNK(const KURL &url, LNKInfo &info) +{ + const char* lnkFile = 0; + + TQString tempFile; + if ( TDEIO::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; + TDEIO::NetAccess::removeTempFile(tempFile); + return false; + } + + LNKHeader header; + + if ( fread(&header, sizeof(header), 1, fd) != 1 ) + { + kdWarning(7034) << "wrong header size" << endl; + fclose(fd); + TDEIO::NetAccess::removeTempFile(tempFile); + return false; + } + + if ( memcmp(header.magic, "L\0\0\0", 4) != 0 ) + { + kdWarning(7034) << "wrong magic in header" << endl; + fclose(fd); + TDEIO::NetAccess::removeTempFile(tempFile); + return false; + } + + if ( header.flags & 0x1 ) // the shell item id list is present + { + TQ_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); + TDEIO::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); + TDEIO::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); + TDEIO::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); + TDEIO::NetAccess::removeTempFile(tempFile); + return false; + } + + info.isNetworkPath = !(loc.flags & 0x1); + + if ( !info.isNetworkPath ) + { + info.volumeName = (start + loc.localVolume + 0x10); // volume label + + info.path = TQString(); + + 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 = TQString("%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 + { + TQ_UINT16 len; + + if ( fread(&len, sizeof(len), 1, fd) != 1 ) + { + kdWarning(7034) << "could not read description string length" << endl; + fclose(fd); + TDEIO::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); + TDEIO::NetAccess::removeTempFile(tempFile); + return false; + } + + data[len] = 0; // nullbyte seems to miss + + info.description = data; + + delete [] data; + } + } + + fclose(fd); + TDEIO::NetAccess::removeTempFile(tempFile); + + return true; +} diff --git a/tdefile-plugins/lnk/read_lnk.h b/tdefile-plugins/lnk/read_lnk.h new file mode 100644 index 0000000..96f3226 --- /dev/null +++ b/tdefile-plugins/lnk/read_lnk.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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 <tqstring.h> +class KURL; + +struct LNKInfo +{ + LNKInfo() : fileSize(0), isNetworkPath(false), isDirectory(false), isFileOrDir(false) {} + + TQ_UINT32 fileSize; + bool isNetworkPath; + bool isDirectory; + bool isFileOrDir; + TQString volumeName; + TQString driveName; + TQString path; + TQString description; +}; + +bool readLNK(const KURL &url, LNKInfo &info); + +#endif diff --git a/tdefile-plugins/lnk/tdefile_lnk.cpp b/tdefile-plugins/lnk/tdefile_lnk.cpp new file mode 100644 index 0000000..b706366 --- /dev/null +++ b/tdefile-plugins/lnk/tdefile_lnk.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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 "tdefile_lnk.h" +#include "read_lnk.h" + +#include <kgenericfactory.h> + +//-------------------------------------------------------------------------------- + +typedef KGenericFactory<lnkPlugin> lnkFactory; + +K_EXPORT_COMPONENT_FACTORY(tdefile_lnk, lnkFactory( "tdefile_lnk" )) + +//-------------------------------------------------------------------------------- + +lnkPlugin::lnkPlugin(TQObject *parent, const char *name, + const TQStringList &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"), TQVariant::Int); + setUnit(item, KFileMimeTypeInfo::Bytes); + + addItemInfo(group, "Where", i18n("Location"), TQVariant::String); + addItemInfo(group, "PointsTo", i18n("Points To"), TQVariant::String); + addItemInfo(group, "Description", i18n("Description"), TQVariant::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", TQString("%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 "tdefile_lnk.moc" diff --git a/tdefile-plugins/lnk/tdefile_lnk.desktop b/tdefile-plugins/lnk/tdefile_lnk.desktop new file mode 100644 index 0000000..b7d28c7 --- /dev/null +++ b/tdefile-plugins/lnk/tdefile_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-TDE-Library=tdefile_lnk +MimeType=application/x-win-lnk +PreferredItems=PointsTo,Where,TargetSize,Description diff --git a/tdefile-plugins/lnk/tdefile_lnk.h b/tdefile-plugins/lnk/tdefile_lnk.h new file mode 100644 index 0000000..3d43dbc --- /dev/null +++ b/tdefile-plugins/lnk/tdefile_lnk.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2004 by Martin Koller * + * [email protected] * + * * + * 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 <$TDEDIR/include/tdefilemetainfo.h> + */ +#include <tdefilemetainfo.h> + +class TQStringList; + +class lnkPlugin: public KFilePlugin +{ + Q_OBJECT + + +public: + lnkPlugin( TQObject *parent, const char *name, const TQStringList& args ); + + virtual bool readInfo( KFileMetaInfo& info, uint what); +}; + +#endif // __KFILE_LNK_H__ + diff --git a/tdefile-plugins/lnk/x-win-lnk.desktop b/tdefile-plugins/lnk/x-win-lnk.desktop new file mode 100644 index 0000000..18429dc --- /dev/null +++ b/tdefile-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 |