summaryrefslogtreecommitdiffstats
path: root/kioslave/mac
diff options
context:
space:
mode:
Diffstat (limited to 'kioslave/mac')
-rw-r--r--kioslave/mac/AUTHORS1
-rw-r--r--kioslave/mac/ChangeLog39
-rw-r--r--kioslave/mac/Makefile.am23
-rw-r--r--kioslave/mac/README65
-rw-r--r--kioslave/mac/TODO14
-rw-r--r--kioslave/mac/cr16-app-mac.pngbin0 -> 679 bytes
-rw-r--r--kioslave/mac/cr32-app-mac.pngbin0 -> 1342 bytes
-rw-r--r--kioslave/mac/kio_mac.cpp561
-rw-r--r--kioslave/mac/kio_mac.h55
-rw-r--r--kioslave/mac/mac.protocol73
10 files changed, 831 insertions, 0 deletions
diff --git a/kioslave/mac/AUTHORS b/kioslave/mac/AUTHORS
new file mode 100644
index 000000000..78b940be4
--- /dev/null
+++ b/kioslave/mac/AUTHORS
@@ -0,0 +1 @@
+Jonathan Riddell, jr@jriddell.org
diff --git a/kioslave/mac/ChangeLog b/kioslave/mac/ChangeLog
new file mode 100644
index 000000000..6c8f647ce
--- /dev/null
+++ b/kioslave/mac/ChangeLog
@@ -0,0 +1,39 @@
+10 Feb 2002 - Jonathan Riddell <jr@jriddell.org>
+ - v1.0
+ - Nicer icon (thanks to ikons project)
+ - moved into KDE CVS kdenonbeta
+ - Everything seems to be stable, lets up the version number to prove me wrong
+
+1 Feb 2002 - Jonathan Riddell <jr@jriddell.org>
+ - v0.8
+ - Now displays hidden files
+ - Locked files are copied as read only
+ - Nice icon
+ - sources now use autoconf/automake
+ - Fixed regular expression which matches some files as directories
+ - Aliases now display as links
+
+26 Jan 2002 - Jonathan Riddell <jr@jriddell.org>
+ - v0.7
+ - Converts some HFS+ file types and application labels into mimetypes
+ - Added a SuSE Makefile
+ - Hopefully managed to get the SuSE RPMs working
+ - When copying files kio-mac now reports the amount progressed so
+ you can see how much has been copied
+ - Text files are now copies over in text mode by default
+
+24 Jan2002 - Jonathan Riddell <jr@jriddell.org>
+ - v0.6
+ - It can now read empty directories without complaining
+ - Fixed the way data was being passed back to KDE which corrupted some files
+ - Fixed Makefile a bit
+ - Now reports the modified date to as good an acuracy as hpls -l gives it
+ - Found a truly bizarre bug while doing the above which broke
+ things a lot less than it should have
+
+21 Jan 2002 - Jonathan Riddell <jr@jriddell.org>
+ - v0.5
+ - Initial release
+ - talks to hfs+ partitions using hptools
+ - surprisingly successful
+
diff --git a/kioslave/mac/Makefile.am b/kioslave/mac/Makefile.am
new file mode 100644
index 000000000..f2f0d97fb
--- /dev/null
+++ b/kioslave/mac/Makefile.am
@@ -0,0 +1,23 @@
+## Makfile.am for kio_mac
+
+INCLUDES= $(all_includes)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+####### Files
+
+kde_module_LTLIBRARIES = kio_mac.la
+
+kio_mac_la_SOURCES = kio_mac.cpp
+kio_mac_la_LIBADD = -lkio
+kio_mac_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+noinst_HEADERS = kio_mac.h
+
+kdelnk_DATA = mac.protocol
+kdelnkdir = $(kde_servicesdir)
+
+METASOURCES = AUTO
+KDE_ICON = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kio_mac.pot
diff --git a/kioslave/mac/README b/kioslave/mac/README
new file mode 100644
index 000000000..bb907dd9c
--- /dev/null
+++ b/kioslave/mac/README
@@ -0,0 +1,65 @@
+From the hfsplus man page:
+
+ "HFS+, also known as the Macintosh Extended Format, was
+ introduced by Apple Computer in 1998 with the release of
+ MacOS 8.1. It contains many improvements over the old HFS
+ file system, most notably the ability to allocate up to
+ 2^64 blocks, resulting in much more efficient storage of
+ many small files on large disks."
+
+This kio slave lets you read an HFS+ partition from konqueror
+or any other KDE file dialogue. It uses hfsplus tools so you will
+need these installed for it to work.
+
+TO INSTALL
+
+Read the INSTALL file.
+
+
+NOTES
+
+Just enter mac:/ into Konqueror and you should see the contents of
+your MacOS partition. Actually you'll probably get an error message
+saying you havn't specified the right partition. Enter something
+like mac:/?dev=/dev/hda2 to specify the partition (if you don't know
+which partition MacOS is on you can probably guess by changing hda2 to
+hda3 and so on or use the print command from mac-fdisk. The partition
+will be used the next time so you don't have to specify it each time.
+
+Hfsplus tools let you see the file and copy data from the HFS+
+partition but not to copy data to it or change the filenames or such like.
+
+HFS+ actually keeps two files for every one you see (called forks), a
+resource fork and a data fork. The default copy mode when you're
+copying files across to you native drive is raw data which means it
+just copies the data. Text files are copied in text mode (same as raw
+format but changes the line endings to be Unix friendly and gets rid
+of some funny extra characters - strongly advised for text files)
+unless you specify otherwise. You can also copy the files across in
+Mac Binary II format or specify text or raw format with another query:
+mac:/myfile?mode=b or mac:/myfile?mode=t See man hpcopy for more.
+
+Note that you need permissions to read your HFS+ partition. How you
+get this depends on your distribution, do a ls -l /dev/hdaX on it to
+see. Under Debian you have to be in the disk group (just add your
+username to the end of the entry in /etc/group).
+
+File types are done with matching the HFS+ type and application label
+and then by extentions. See the source for the exact matching that
+happens and feel free to suggest improvements.
+
+For some reason some directories in MacOS end in a funny tall f
+character. This seems to confuse hfstools.
+
+You can't easiily use the command line tools while you are browsing
+using kio-mac in Konqueror. Konqueror continuously refreshes it's
+view which mean hpmount is being called every few seconds. Click on
+Konqueror's home button before using the tools yourself on the command
+line.
+
+Hidden files are now shown all the time. Apparantly Konqueror only
+considers files with a dot at the front of the name to be hidden which
+is a bit system dependant.
+
+Please e-mail me with any comments, problems and success stories:
+Jonathan Riddell, jr@jriddell.org
diff --git a/kioslave/mac/TODO b/kioslave/mac/TODO
new file mode 100644
index 000000000..e94d88254
--- /dev/null
+++ b/kioslave/mac/TODO
@@ -0,0 +1,14 @@
+FIXMEs:
+ Amazingly, none that I can think of
+
+grep TODO kio_mac.cpp
+ //TODO this means dev=foo must be the last argument in the query
+ //TODO this error interrupts the user when typing ?dev=foo on each letter of foo
+ //TODO are there any more characters to escape?
+ QString theSize(fileRE.group(4)); //TODO: this is data size, what about resource size?
+
+Future things:
+ - maybe make it work with plain old hfs partitions
+ - possibly use libhfsp directly
+ - A Friend suggested reading the resource data for the icon to display - advanced I think.
+ - Follow symlinks/aliases (requires reading the resource fork as well)
diff --git a/kioslave/mac/cr16-app-mac.png b/kioslave/mac/cr16-app-mac.png
new file mode 100644
index 000000000..930694eab
--- /dev/null
+++ b/kioslave/mac/cr16-app-mac.png
Binary files differ
diff --git a/kioslave/mac/cr32-app-mac.png b/kioslave/mac/cr32-app-mac.png
new file mode 100644
index 000000000..87df6fb85
--- /dev/null
+++ b/kioslave/mac/cr32-app-mac.png
Binary files differ
diff --git a/kioslave/mac/kio_mac.cpp b/kioslave/mac/kio_mac.cpp
new file mode 100644
index 000000000..56989487a
--- /dev/null
+++ b/kioslave/mac/kio_mac.cpp
@@ -0,0 +1,561 @@
+/***************************************************************************
+ kio_mac.cpp
+ -------------------
+ copyright : (C) 2002 Jonathan Riddell
+ email : jr@jriddell.org
+ version : 1.0.1
+ release date : 19 July 2002
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#define PARTITION "/dev/hda11"
+
+#include <kinstance.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <qstring.h>
+#include <qregexp.h>
+
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <iostream>
+#include <time.h>
+
+#include "kio_mac.moc"
+
+using namespace KIO;
+
+extern "C" {
+ int KDE_EXPORT kdemain(int, char **argv) {
+ KInstance instance("kio_mac");
+ MacProtocol slave(argv[2], argv[3]);
+ slave.dispatchLoop();
+ return 0;
+ }
+}
+
+MacProtocol::MacProtocol(const QCString &pool, const QCString &app)
+ : QObject(), SlaveBase("mac", pool, app) {
+/* logFile = new QFile("/home/jr/logfile");
+ logFile->open(IO_ReadWrite | IO_Append);
+ logStream = new QTextStream(logFile);
+ *logStream << "Start Macprotocol()" << endl;
+ */
+}
+
+MacProtocol::~MacProtocol() {
+/* *logStream << "destructor ~MacProtocol()" << endl;
+ logFile->close();
+ delete logFile;
+ logFile = 0;
+ delete logStream;
+ logStream = 0;
+*/
+ delete myKProcess;
+ myKProcess = 0L;
+}
+
+//get() called when a file is to be read
+void MacProtocol::get(const KURL& url) {
+ QString path = prepareHP(url); //mount and change to correct directory - return the filename
+ QString query = url.query();
+ QString mode("-");
+ QString mime;
+ processedBytes = 0;
+
+ //Find out the size and if it's a text file
+ UDSEntry entry = doStat(url);
+ UDSEntry::Iterator it;
+ for(it = entry.begin(); it != entry.end(); ++it) {
+ if ((*it).m_uds == KIO::UDS_MIME_TYPE) {
+ mime = (*it).m_str;
+ }
+ if ((*it).m_uds == KIO::UDS_SIZE) {
+ totalSize((*it).m_long);
+ }
+ }
+
+ //find out if a mode has been specified in the query e.g. ?mode=t
+ //or if it's a text file then set the mode to text
+ int modepos = query.find("mode=");
+ int textpos = mime.find("text");
+ if (modepos != -1) {
+ mode += query.mid(modepos + 5, 1);
+ if (mode != "-r" && mode != "-b" && mode != "-m" && mode != "-t" && mode != "-a") {
+ error(ERR_SLAVE_DEFINED, i18n("Unknown mode"));
+ }
+ } else if (textpos != -1) {
+ mode += "t";
+ } else {
+ mode += "r";
+ }
+
+ //now we can read the file
+ myKProcess = new KProcess();
+
+ *myKProcess << "hpcopy" << mode << path << "-";
+
+ //data is now sent directly from the slot
+ connect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, SLOT(slotSetDataStdOutput(KProcess *, char *, int)));
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ if (!myKProcess->normalExit() || !(myKProcess->exitStatus() == 0)) {
+ error(ERR_SLAVE_DEFINED,
+ i18n("There was an error with hpcopy - please ensure it is installed"));
+ return;
+ }
+
+ //clean up
+ delete myKProcess; myKProcess = 0;
+ //finish
+ data(QByteArray());
+ finished();
+}
+
+//listDir() called when the user is looking at a directory
+void MacProtocol::listDir(const KURL& url) {
+ QString filename = prepareHP(url);
+
+ if (filename.isNull()) {
+ error(ERR_CANNOT_LAUNCH_PROCESS, i18n("No filename was found"));
+ } else {
+ myKProcess = new KProcess();
+ *myKProcess << "hpls" << "-la" << filename;
+
+ standardOutputStream = QString::null;
+ connect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ if ((!myKProcess->normalExit()) || (!myKProcess->exitStatus() == 0)) {
+ error(ERR_SLAVE_DEFINED,
+ i18n("There was an error with hpls - please ensure it is installed"));
+ }
+
+ //clean up
+ delete myKProcess; myKProcess = 0;
+ disconnect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ UDSEntry entry;
+ if (!standardOutputStream.isEmpty()) {
+ QTextStream in(&standardOutputStream, IO_ReadOnly);
+ QString line = in.readLine(); //throw away top file which shows current directory
+ line = in.readLine();
+
+ while (line != NULL) {
+ //1.0.4 puts this funny line in sometimes, we don't want it
+ if (line.contains("Thread ") == 0) {
+ entry = makeUDS(line);
+ listEntry(entry, false);
+ }
+ line = in.readLine();
+ }
+ }//if standardOutputStream != null
+
+ listEntry(entry, true);
+ finished();
+
+ }//if filename == null
+}
+
+//stat() called to see if it's a file or directory, called before listDir() or get()
+void MacProtocol::stat(const KURL& url) {
+ statEntry(doStat(url));
+ finished();
+}
+
+//doStat(), does all the work that stat() needs
+//it's been separated out so it can be called from get() which
+//also need information
+QValueList<KIO::UDSAtom> MacProtocol::doStat(const KURL& url) {
+ QString filename = prepareHP(url);
+
+ if (filename.isNull()) {
+ error(ERR_SLAVE_DEFINED, i18n("No filename was found in the URL"));
+ } else if (! filename.isEmpty()) {
+ myKProcess = new KShellProcess();
+
+ *myKProcess << "hpls" << "-ld" << filename;
+
+ standardOutputStream = QString::null;
+ connect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ if ((!myKProcess->normalExit()) || (!myKProcess->exitStatus() == 0)) {
+ error(ERR_SLAVE_DEFINED,
+ i18n("hpls did not exit normally - please ensure you have installed the hfsplus tools"));
+ }
+
+ //clean up
+ delete myKProcess; myKProcess = 0;
+ disconnect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ if (standardOutputStream.isEmpty()) {
+ filename.replace("\\ ", " "); //get rid of escapes
+ filename.replace("\\&", "&"); //mm, slashes...
+ filename.replace("\\!", "!");
+ filename.replace("\\(", "(");
+ filename.replace("\\)", ")");
+ error(ERR_DOES_NOT_EXIST, filename);
+ } else {
+ //remove trailing \n
+ QString line = standardOutputStream.left(standardOutputStream.length()-1);
+ UDSEntry entry = makeUDS(line);
+ return entry;
+ }
+ } else { //filename is empty means we're looking at root dir
+ //we don't have a listing for the root directory so here's a dummy one
+ UDSEntry entry = makeUDS("d 0 item Jan 01 2000 /");
+ return entry;
+ }//if filename == null
+
+ return QValueList<KIO::UDSAtom>();
+}
+
+//prepareHP() called from get() listDir() and stat()
+//(re)mounts the partition and changes to the appropriate directory
+QString MacProtocol::prepareHP(const KURL& url) {
+ QString path = url.path(-1);
+ if (path.left(1) == "/") {
+ path = path.mid(1); // strip leading slash
+ }
+
+ //find out if a device has been specified in the query e.g. ?dev=/dev/fd0
+ //or in the config file (query device entries are saved to config file)
+ QString device;
+ KConfig* config = new KConfig("macrc");
+
+ QString query = url.query();
+ int modepos = query.find("dev=");
+ if (modepos == -1) {
+ //no device specified, read from config or go with #define PARTITION
+ device = config->readEntry("device",PARTITION);
+ } else {
+ //TODO this means dev=foo must be the last argument in the query
+ device = query.mid(modepos + 4);
+ config->writeEntry("device",device);
+ }
+ delete config; config = 0;
+
+ //first we run just hpmount and check the output to see if it's version 1.0.2 or 1.0.4
+ myKProcess = new KProcess();
+ *myKProcess << "hpmount";
+ standardOutputStream = QString::null;
+ connect(myKProcess, SIGNAL(receivedStderr(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ bool version102 = true;
+
+ if (standardOutputStream.contains("options") != 0) {
+ version102 = false;
+ }
+
+ delete myKProcess; myKProcess = 0;
+ disconnect(myKProcess, SIGNAL(receivedStderr(KProcess *, char *, int)),
+ this, SLOT(slotGetStdOutput(KProcess *, char *, int)));
+
+ //now mount the drive
+ myKProcess = new KProcess();
+ if (version102) {
+ *myKProcess << "hpmount" << device;
+ } else {
+ *myKProcess << "hpmount" << "-r" << device;
+ }
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ if ((!myKProcess->normalExit()) || (!myKProcess->exitStatus() == 0)) {
+ //TODO this error interrupts the user when typing ?dev=foo on each letter of foo
+ error(ERR_SLAVE_DEFINED,
+ i18n("hpmount did not exit normally - please ensure that hfsplus utils are installed,\n"
+ "that you have permission to read the partition (ls -l /dev/hdaX)\n"
+ "and that you have specified the correct partition.\n"
+ "You can specify partitions by adding ?dev=/dev/hda2 to the URL."));
+ return NULL;
+ }
+
+ //clean up
+ delete myKProcess; myKProcess = 0;
+
+ //escape any funny characters
+ //TODO are there any more characters to escape?
+ path.replace(" ", "\\ ");
+ path.replace("&", "\\&");
+ path.replace("!", "\\!");
+ path.replace("(", "\\(");
+ path.replace(")", "\\)");
+
+ //then change to the right directory
+ int s; QString dir;
+ s = path.find('/');
+ while (s != -1) {
+ dir = path.left(s);
+ path = path.mid(s+1);
+
+ myKProcess = new KProcess();
+ *myKProcess << "hpcd" << dir;
+
+ myKProcess->start(KProcess::Block, KProcess::All);
+
+ if ((!myKProcess->normalExit()) || (!myKProcess->exitStatus() == 0)) {
+ error(ERR_SLAVE_DEFINED,
+ i18n("hpcd did not exit normally - please ensure it is installed"));
+ return NULL;
+ }
+
+ //clean up
+ delete myKProcess; myKProcess = 0;
+
+ s = path.find('/');
+ }
+
+ return path;
+}
+
+//makeUDS() takes a line of output from hpls -l and converts it into
+// one of these UDSEntrys to return
+//called from listDir() and stat()
+QValueList<KIO::UDSAtom> MacProtocol::makeUDS(const QString& _line) {
+ QString line(_line);
+ UDSEntry entry;
+
+ //is it a file or a directory
+ QRegExp dirRE("^d. +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +(.*)");
+ QRegExp fileRE("^([f|F]). +(....)/(....) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +(.*)");
+ if (dirRE.exactMatch(line)) {
+ UDSAtom atom;
+ atom.m_uds = KIO::UDS_NAME;
+ atom.m_str = dirRE.cap(6);
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_MODIFICATION_TIME;
+ atom.m_long = makeTime(dirRE.cap(4), dirRE.cap(3), dirRE.cap(5));
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_FILE_TYPE;
+ atom.m_long = S_IFDIR;
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_ACCESS;
+ atom.m_long = 0755;
+ entry.append(atom);
+
+ } else if (fileRE.exactMatch(line)) {
+ UDSAtom atom;
+ atom.m_uds = KIO::UDS_NAME;
+ atom.m_str = fileRE.cap(9);
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_SIZE;
+ QString theSize(fileRE.cap(4)); //TODO: this is data size, what about resource size?
+ atom.m_long = theSize.toLong();
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_MODIFICATION_TIME;
+ atom.m_long = makeTime(fileRE.cap(7), fileRE.cap(6), fileRE.cap(8));
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_ACCESS;
+ if (QString(fileRE.cap(1)) == QString("F")) { //if locked then read only
+ atom.m_long = 0444;
+ } else {
+ atom.m_long = 0644;
+ }
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_MIME_TYPE;
+ QString mimetype = getMimetype(fileRE.cap(2),fileRE.cap(3));
+ atom.m_str = mimetype.local8Bit();
+ entry.append(atom);
+
+ // Is it a file or a link/alias, just make aliases link to themselves
+ if (QString(fileRE.cap(2)) == QString("adrp") ||
+ QString(fileRE.cap(2)) == QString("fdrp")) {
+ atom.m_uds = KIO::UDS_FILE_TYPE;
+ atom.m_long = S_IFREG;
+ entry.append(atom);
+
+ atom.m_uds = KIO::UDS_LINK_DEST;
+ atom.m_str = fileRE.cap(9); //I have a file called "Mozilla alias" the name
+ // of which displays funny because of this.
+ // No idea why. Same for other kioslaves. A font thing?
+ entry.append(atom);
+ } else {
+ atom.m_uds = KIO::UDS_FILE_TYPE;
+ atom.m_long = S_IFREG;
+ entry.append(atom);
+ }
+ } else {
+ error(ERR_INTERNAL, i18n("hpls output was not matched"));
+ } //if match dirRE or fileRE
+
+ return entry;
+}
+
+//slotGetStdOutput() grabs output from the hp commands
+// and adds it to the buffer
+void MacProtocol::slotGetStdOutput(KProcess*, char *s, int len) {
+ standardOutputStream += QString::fromLocal8Bit(s, len);
+}
+
+//slotSetDataStdOutput() is used during hpcopy to give
+//standard output to KDE
+void MacProtocol::slotSetDataStdOutput(KProcess*, char *s, int len) {
+ processedBytes += len;
+ processedSize(processedBytes);
+ QByteArray array;
+ array.setRawData(s, len);
+ data(array);
+ array.resetRawData(s, len);
+}
+
+//makeTime() takes in the date output from hpls -l
+//and returns as good a timestamp as we're going to get
+int MacProtocol::makeTime(QString mday, QString mon, QString third) {
+ int year; int month; int day;
+ int hour; int minute;
+
+ //find the month
+ if (mon == "Jan") { month = 1; }
+ else if (mon == "Feb") { month = 2; }
+ else if (mon == "Mar") { month = 3; }
+ else if (mon == "Apr") { month = 4; }
+ else if (mon == "May") { month = 5; }
+ else if (mon == "Jun") { month = 6; }
+ else if (mon == "Jul") { month = 7; }
+ else if (mon == "Aug") { month = 8; }
+ else if (mon == "Sep") { month = 9; }
+ else if (mon == "Oct") { month = 10; }
+ else if (mon == "Nov") { month = 11; }
+ else if (mon == "Dec") { month = 12; }
+ else {
+ error(ERR_INTERNAL, i18n("Month output from hpls -l not matched"));
+ month = 13;
+ }
+
+ //if the file is recent (last 12 months) hpls gives us the time,
+ // otherwise it only prints the year
+ QRegExp hourMin("(..):(..)");
+ if (hourMin.exactMatch(third)) {
+ QDate currentDate(QDate::currentDate());
+
+ if (month > currentDate.month()) {
+ year = currentDate.year() - 1;
+ } else {
+ year = currentDate.year();
+ }
+ QString h(hourMin.cap(1));
+ QString m(hourMin.cap(2));
+ hour = h.toInt();
+ minute = m.toInt();
+ } else {
+ year = third.toInt();
+ hour = 0;
+ minute = 0;
+ }// if hour:min or year
+
+ day = mday.toInt();
+
+ //check it's valid
+ if ( (!QDate::isValid(year, month, day)) || (!QTime::isValid(hour, minute, 0) ) ) {
+ error(ERR_INTERNAL, i18n("Could not parse a valid date from hpls"));
+ }
+
+ //put it together and work it out
+ QDate fileDate(year, month, day);
+ QTime fileTime(hour, minute);
+ QDateTime fileDateTime(fileDate, fileTime);
+
+ return fileDateTime.toTime_t();
+}
+
+QString MacProtocol::getMimetype(QString type, QString app) {
+ if (type == QString("TEXT") && app == QString("ttxt")) {
+ return QString("text/plain");
+ } else if (type == QString("TEXT") && app == QString("udog")) {
+ return QString("text/html");
+ } else if (type == QString("svgs")) {
+ return QString("text/xml");
+ } else if (type == QString("ZIP ")) {
+ return QString("application/zip");
+ } else if (type == QString("pZip")) {
+ return QString("application/zip");
+ } else if (type == QString("APPL")) {
+ return QString("application/x-executable");
+ } else if (type == QString("MooV")) {
+ return QString("video/quicktime");
+ } else if (type == QString("TEXT") && app == QString("MSWD")) {
+ return QString("application/vnd.ms-word");
+ } else if (type == QString("PDF ")) {
+ return QString("application/pdf");
+ } else if (app == QString("CARO")) {
+ return QString("application/pdf");
+ } else if (type == QString("SIT5")) {
+ return QString("application/x-stuffit");
+ } else if (type == QString("SITD")) {
+ return QString("application/x-stuffit");
+ } else if (type == QString("SIT!")) {
+ return QString("application/x-stuffit");
+ } else if (app == QString("SIT!")) {
+ return QString("application/x-stuffit");
+ } else if (type == QString("RTFf")) {
+ return QString("text/rtf");
+ } else if (type == QString("GIFf")) {
+ return QString("image/gif");
+ } else if (type == QString("JPEG")) {
+ return QString("image/jpeg");
+ } else if (type == QString("PNGf")) {
+ return QString("image/png");
+ } else if (type == QString("XBMm")) {
+ return QString("image/x-xbm");
+ } else if (type == QString("EPSF")) {
+ return QString("image/x-epsf");
+ } else if (type == QString("TIFF")) {
+ return QString("image/tiff");
+ } else if (type == QString("PICT")) {
+ return QString("image/pict");
+ } else if (type == QString("TPIC")) {
+ return QString("image/x-targa");
+ } else if (type == QString("ULAW")) {
+ return QString("audio/basic");
+ } else if (type == QString("AIFF")) {
+ return QString("audio/x-aiff");
+ } else if (type == QString("WAVE")) {
+ return QString("audio/x-wav");
+ } else if (type == QString("FFIL") && app == QString("DMOV")) {
+ return QString("application/x-font");
+ } else if (type == QString("XLS3")) {
+ return QString("application/vnd.ms-excel");
+ } else if (type == QString("XLS4")) {
+ return QString("application/vnd.ms-excel");
+ } else if (type == QString("XLS5")) {
+ return QString("application/vnd.ms-excel");
+ } else if (app == QString("MSWD")) {
+ return QString("application/vnd.ms-word");
+ } else if (type == QString("TEXT")) {
+ return QString("text/plain");
+ } else if (app == QString("ttxt")) {
+ return QString("text/plain");
+ }
+ return QString("application/octet-stream");
+}
+
+
diff --git a/kioslave/mac/kio_mac.h b/kioslave/mac/kio_mac.h
new file mode 100644
index 000000000..c87217e08
--- /dev/null
+++ b/kioslave/mac/kio_mac.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ mac.cpp
+ -------------------
+ copyright : (C) 2002 Jonathan Riddell
+ email : jr@jriddell.org
+ version : 1.0
+ release date : 10 Feburary 2002
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <kio/slavebase.h>
+#include <kio/global.h>
+#include <kurl.h>
+#include <kprocess.h>
+
+#include <qstring.h>
+#include <qcstring.h>
+#include <qfile.h>
+#include <qtextstream.h>
+
+class MacProtocol : public QObject, public KIO::SlaveBase
+{
+ Q_OBJECT
+public:
+ MacProtocol(const QCString &pool, const QCString &app);
+ ~MacProtocol();
+ virtual void get(const KURL& url );
+ virtual void listDir(const KURL& url);
+ virtual void stat(const KURL& url);
+protected slots:
+ void slotGetStdOutput(KProcess*, char*, int);
+ void slotSetDataStdOutput(KProcess*, char *s, int len);
+protected:
+ QString prepareHP(const KURL& _url);
+ QValueList<KIO::UDSAtom> makeUDS(const QString& _line);
+ int makeTime(QString mday, QString mon, QString third);
+ QString getMimetype(QString type, QString app);
+ QValueList<KIO::UDSAtom> doStat(const KURL& url);
+
+ KIO::filesize_t processedBytes;
+ QString standardOutputStream;
+ KProcess* myKProcess;
+
+ //for debugging
+ //QFile* logFile;
+ //QTextStream* logStream;
+};
diff --git a/kioslave/mac/mac.protocol b/kioslave/mac/mac.protocol
new file mode 100644
index 000000000..cef77621d
--- /dev/null
+++ b/kioslave/mac/mac.protocol
@@ -0,0 +1,73 @@
+[Protocol]
+exec=kio_mac
+protocol=mac
+input=none
+output=filesystem
+reading=true
+listing=Name,Type,Size,Date
+defaultMimetype=application/octet-stream
+Description=A kioslave for MacOS HFS+ partitions
+Description[af]='n Kioslave vir MacOS HFS+ partisies
+Description[be]=Kioslave для раздзелаў MacOS HFS+
+Description[bn]=ম্যাক-ও-এস HFS+ পার্টিশন-এর জন্য একটি kioslave
+Description[br]=Ur c'hioslave evit ar parzhadurioù MacOS HFS+
+Description[bs]=kioslave za MacOS HFS+ particije
+Description[ca]=Un kioslave per a particions MacOS HFS+
+Description[cs]=Pomocný protokol pro diskové oddíly MacOS HFS+
+Description[csb]=Plugins protokòłu dlô particëji HFS+ systemë MacOS
+Description[da]=En kioslave for MacOS HFS+ partitioner
+Description[de]=Ein-/Ausgabemodul für MacOS HFS+ Partitionen
+Description[el]=Ένας kioslave για κατατμήσεις MacOS HFS+
+Description[eo]=K-enel-sklavo por MacOS HFS+ subdiskoj
+Description[es]=Un kioslave para particiones MacOS HFS+
+Description[et]=MacOS-i HFS+-partitsioonide IO-moodul
+Description[eu]=MacOS HFS+ zatiketetarako kioslavea
+Description[fa]=یک kioslave برای افرازهای HFS+ سیستم عامل مکینتاش
+Description[fi]=Liitäntä MacOS HFS+ osioinneille
+Description[fr]=Un module d'entrées / sorties pour les partitions MacOS HFS+
+Description[fy]=In kioslave foar MacOS HFS+-partities
+Description[ga]=kioslave le haghaidh deighiltí MacOS HFS+
+Description[gl]=Un kioslave para particións MacOS HFS+
+Description[he]=ממשק kioslave עבור מחיצות MacOS HFS+
+Description[hi]=मॅक-ओएस एचएफ़एस+ पार्टीशनों के लिए के-आई-ओ-स्लेव
+Description[hr]=Kioslave za MacOS HFS+ particije
+Description[hu]=KDE-protokoll MacOS HFS+ partíciók kezeléséhez
+Description[is]=kioslave fyrir MacOS HFS+ disksneiðar
+Description[it]=Un kioslave per partizioni MacOS HFS+
+Description[ja]=MacOS HFS+ パーティションのための kioslave
+Description[ka]=kioslave MacOS HFS+ პარტიციებისთვის
+Description[kk]=MacOS HFS+ файл жүйесінің енгізу-шығару модулі
+Description[km]=kioslave សម្រាប់​ភាគ MacOS HFS+
+Description[lt]=Kiovergas MacOS HFS+ dalmenims
+Description[lv]=KIO vergs MacOS HFS+ partīcijām
+Description[mk]=kio-служител за HFS+ партиции од MacOS
+Description[ms]=Hamba kio untuk MacOS HFS+ petak
+Description[nb]=En kioskslave for MacOS HFS+-partisjoner
+Description[nds]=En In-/Utgaavdeenst för MacOS-HFS+-Partitschonen
+Description[ne]=MacOS HFS+ विभाजनका लागि किओस्लेभ
+Description[nl]=Een kioslave voor MacOS HFS+-partities
+Description[nn]=Ein IU-slave for MacOS HFS+-partisjonar
+Description[pa]=MacOS HFS+ ਭਾਗਾਂ ਲਈ kioslave
+Description[pl]=Wtyczka protokołu dla partycji HFS+ systemu MacOS
+Description[pt]=Um 'kioslave' para partições MacOS HFS+
+Description[pt_BR]=Um protocolo para as partições HFS+ do MacOS
+Description[ro]=Un dispozitiv de I/E pentru partiții HFS+ MacOS
+Description[ru]=Модуль ввода-вывода для файловой системы MacOS HFS+
+Description[rw]=Kio-umugaragu ya MacOS HFS+ibicedisiki
+Description[se]=SO-šláva MacOS HFS+-partišuvnnaid várás
+Description[sk]=kioslave pre MacOS HFS+
+Description[sl]=kioslave za razdelke MacOS HFS+
+Description[sr]=Kioslave за MacOS-ове HFS+ партиције
+Description[sr@Latn]=Kioslave za MacOS-ove HFS+ particije
+Description[sv]=En I/O-slav för MacOS HFS+ partitioner
+Description[ta]=MacOS HFS+ partitionsக்கு ஒரு க்யோஸ்லேவ்
+Description[th]=ตัวนำข้อมูลเข้า-ออกสำหรับพาร์ติชั่นที่ใช้ระบบไฟล์ HFS+ ของ MacOS
+Description[tr]=MacOS HFS+ bölümleri için kioslave
+Description[tt]=MacOS HFS+ bülemnäre öçen birem sistemeneñ modulı
+Description[uk]=Підлеглий B/В для розділів MacOS HFS+
+Description[vi]=A kioslave (đày tớ vào ra KDE) cho MacOS HFS và các phân vùng
+Description[wa]=On kioslave po MacOS HFS + pårticions
+Description[zh_CN]=MacOS HFS+ 分区的 KIO 仆人
+Description[zh_TW]=用於 MacOS HFS+ 分割區的 kioslave
+Icon=mac
+DocPath=kioslave/mac.html