File indexing completed on 2024-03-24 16:22:06
0001 /** 0002 * Copyright (C) 2006 by Koos Vriezen <koos.vriezen@gmail.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License version 2 as published by the Free Software Foundation. 0007 * 0008 * This library is distributed in the hope that it will be useful, 0009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 * Library General Public License for more details. 0012 * 0013 * You should have received a copy of the GNU Library General Public License 0014 * along with this library; see the file COPYING.LIB. If not, write to 0015 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, 0016 * Boston, MA 02110-1301, USA. 0017 **/ 0018 0019 #include "config-kmplayer.h" 0020 #include <kdebug.h> 0021 #include <kurl.h> 0022 0023 #include "kmplayer_opml.h" 0024 #include "expression.h" 0025 0026 using namespace KMPlayer; 0027 0028 0029 KDE_NO_EXPORT Node *OPML::Opml::childFromTag (const QString & tag) 0030 { 0031 QByteArray ba = tag.toLatin1 (); 0032 const char *name = ba.constData (); 0033 if (!strcasecmp (name, "head")) 0034 return new Head (m_doc); 0035 else if (!strcasecmp (name, "body")) 0036 return new Body (m_doc); 0037 return 0L; 0038 } 0039 0040 void OPML::Opml::closed () 0041 { 0042 Expression *expr = evaluateExpr ("/head/title"); 0043 if (expr) { 0044 expr->setRoot (this); 0045 title = expr->toString (); 0046 delete expr; 0047 } 0048 Element::closed (); 0049 } 0050 0051 void *OPML::Opml::role (RoleType msg, void *content) 0052 { 0053 if (RolePlaylist == msg) 0054 return !title.isEmpty () ? (PlaylistRole *) this : NULL; 0055 return Element::role (msg, content); 0056 } 0057 0058 //--------------------------%<------------------------------------------------- 0059 0060 Node *OPML::Head::childFromTag (const QString & tag) 0061 { 0062 QByteArray ba = tag.toLatin1 (); 0063 const char *name = ba.constData (); 0064 if (!strcasecmp (name, "title")) 0065 return new DarkNode (m_doc, name, id_node_title); 0066 else if (!strcasecmp (name, "dateCreated")) 0067 return new DarkNode (m_doc, name, id_node_ignore); 0068 return 0L; 0069 } 0070 0071 //--------------------------%<------------------------------------------------- 0072 0073 Node *OPML::Body::childFromTag (const QString & tag) 0074 { 0075 QByteArray ba = tag.toLatin1 (); 0076 const char *name = ba.constData (); 0077 if (!strcasecmp (name, "outline")) 0078 return new Outline (m_doc); 0079 return 0L; 0080 } 0081 0082 //--------------------------%<------------------------------------------------- 0083 0084 void OPML::Outline::closed () 0085 { 0086 src = getAttribute ("xmlUrl").trimmed (); 0087 title = getAttribute ("title").trimmed (); 0088 Mrl::closed (); 0089 }