• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kioslave

metainfo.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002     Copyright (C) 2002 Rolf Magnus <ramagnus@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation version 2.0
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 */
00018 
00019 // $Id: metainfo.cpp 465272 2005-09-29 09:47:40Z mueller $
00020 
00021 #include <kdatastream.h> // Do not remove, needed for correct bool serialization
00022 #include <kurl.h>
00023 #include <kapplication.h>
00024 #include <kmimetype.h>
00025 #include <kdebug.h>
00026 #include <kfilemetainfo.h>
00027 #include <klocale.h>
00028 #include <stdlib.h>
00029 
00030 #include "metainfo.h"
00031 
00032 // Recognized metadata entries:
00033 // mimeType     - the mime type of the file, so we need not extra determine it
00034 // what         - what to load
00035  
00036 using namespace KIO;
00037 
00038 extern "C"
00039 {
00040     KDE_EXPORT int kdemain(int argc, char **argv);
00041 }
00042 
00043 int kdemain(int argc, char **argv)
00044 {
00045     KApplication app(argc, argv, "kio_metainfo", false, true);
00046 
00047     if (argc != 4)
00048     {
00049         kdError() << "Usage: kio_metainfo protocol domain-socket1 domain-socket2" << endl;
00050         exit(-1);
00051     }
00052 
00053     MetaInfoProtocol slave(argv[2], argv[3]);
00054     slave.dispatchLoop();
00055 
00056     return 0;
00057 }
00058 
00059 MetaInfoProtocol::MetaInfoProtocol(const QCString &pool, const QCString &app)
00060     : SlaveBase("metainfo", pool, app)
00061 {
00062 }
00063 
00064 MetaInfoProtocol::~MetaInfoProtocol()
00065 {
00066 }
00067 
00068 void MetaInfoProtocol::get(const KURL &url)
00069 {
00070     QString mimeType = metaData("mimeType");
00071     KFileMetaInfo info(url.path(), mimeType);
00072     
00073     QByteArray arr;
00074     QDataStream stream(arr, IO_WriteOnly);
00075 
00076     stream << info;
00077 
00078     data(arr);
00079     finished();
00080 }
00081 
00082 void MetaInfoProtocol::put(const KURL& url, int, bool, bool) 
00083 {
00084     QString mimeType = metaData("mimeType");
00085     KFileMetaInfo info;
00086     
00087     QByteArray arr;
00088     readData(arr);
00089     QDataStream stream(arr, IO_ReadOnly);
00090     
00091     stream >> info;
00092 
00093     if (info.isValid())
00094     {
00095         info.applyChanges();
00096     } 
00097     else 
00098     {
00099         error(ERR_NO_CONTENT, i18n("No metainfo for %1").arg(url.path()));
00100         return;
00101     }
00102     finished();
00103 }  

kioslave

Skip menu "kioslave"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal