kitchensync
pluckerfilehandle.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "pluckerfilehandle.h"
00023 #include "pluckerconfig.h"
00024
00025 #include <konnector.h>
00026 #include <kstandarddirs.h>
00027
00028 #include <qfile.h>
00029 #include <qtextstream.h>
00030
00031 namespace KSPlucker {
00032
00033 void PluckerFileHandle::addFile( const KURL& url, const QString& uid, bool site )
00034 {
00035 QString md5 = KSync::Konnector::generateMD5Sum( url.path() );
00036 QString file = locateLocal( "appdata", "plucker-"+uid+"/"+md5+".jxl" );
00037 QString name = site ? "site" : "feed";
00038
00039 QFile f( file );
00040
00041 if ( f.exists() || !f.open( IO_WriteOnly) )
00042 return;
00043
00044 QTextStream str( &f );
00045 str.setEncoding( QTextStream::UnicodeUTF8 );
00046 str << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
00047 str << "<jxl lastEdited=\"2004-08-31T11:12:03\" "
00048 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
00049 "xsi:noNamespaceSchemaLocation=\"http://jpluck.sourceforge.net/jxl/jxl-2.1.xsd\">\n";
00050 str << "\t<"+name+">\n\t\t<name>KitchenSync Added URL"+md5+"</name>\n";
00051 str << "\t\t<uri>"+url.url()+"</uri>\n";
00052 str << "\t</"+name+">\n</jxl>\n";
00053
00054
00055 PluckerConfig* conf = PluckerConfig::self();
00056 QStringList lst = conf->pluckerFiles();
00057 if ( !lst.contains( file ) )
00058 lst.append( file );
00059
00060 conf->setPluckerFiles( lst );
00061 conf->save( uid );
00062 }
00063
00064 }
|