[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/kiosktool
From:       Ian Reinhart Geiser <geiseri () kde ! org>
Date:       2009-03-01 15:09:38
Message-ID: 1235920178.149960.20722.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933756 by geiseri:

Start migration to new kiosk ini data format.  This will allow 3rd party 
application  developers to supply data files so that kiosk tool knows how to lock 
down their applications.  To get this support developers should create 
a .kiosk data file and install it into the kisoktool application data directory.

The other advantage of this being an ini style format is i18n is handled right in 
the config file, so translations are possible.



 M  +2 -0      CMakeLists.txt  
 M  +25 -0     README  
 A             data (directory)  
 A             data/general.kisok  
 A             data/sample.kisok  
 M  +62 -141   kioskdata.cpp  
 M  +8 -6      kioskdata.h  
 M  +0 -2      kioskrun.cpp  
 M  +3 -0      menueditComponent.cpp  
 M  +0 -1      panelComponent.cpp  


--- trunk/extragear/sysadmin/kiosktool/CMakeLists.txt #933755:933756
@@ -61,6 +61,8 @@
 FILE(GLOB captionfiles caption*.png)
 install( FILES ${captionfiles} DESTINATION ${DATA_INSTALL_DIR}/kiosktool )
 
+install( FILES data/general.kisok DESTINATION ${DATA_INSTALL_DIR}/kiosktool )
+
 kde4_install_icons( ${ICON_INSTALL_DIR} )
 
 install( FILES kiosktoolui.rc kiosk_data.xml  background.png logo.png DESTINATION  \
                ${DATA_INSTALL_DIR}/kiosktool )
--- trunk/extragear/sysadmin/kiosktool/README #933755:933756
@@ -11,3 +11,28 @@
 
 Waldo Bastian
 bastian@kde.org
+
+
+Application Developers:
+If you wish to allow your application to be managed by Kiosk Tool you 
+can provide a kiosk file and install it into $KDEDATADIR/kiosktool/yourapp.kisok
+
+The format is reasonably simple and you can install as many .kiosk files as
+you wish.  Every .kiosk file must have a "Group" section.  This is the meta
+information that will be used to display the group in the main UI.  There
+are three entries that are all required; Icon, Description, and Name.  Icon
+is the base name of the icon you wish to display in the UI and Name is the
+text that will appear under the icon.  Description will appear in a tooltip
+for the icon.
+
+The action section is a bit more involved. Each action is in its own group
+and must have a unique name.  The fields are as follows:
+Type - immutable, action restriction, resource restriction, module, custom, and \
config. +File - The rc file that will be used to store the settings in.
+Key - The key in the rc file that will be modified.
+Group - The group in the rc file that contains the key that will be modified.
+Name - The name that will appear in the UI for the action.
+Description - The longer description that will be displayed in a status message in \
the UI. +Default - If the default value for the property should be supplied.
+Version - The verison when the key action was introduced.
+
--- trunk/extragear/sysadmin/kiosktool/kioskdata.cpp #933755:933756
@@ -20,7 +20,6 @@
 
 #include "kioskdata.h"
 
-#include <QDomElement>
 #include <QFile>
 
 #include <KDE/KAction>
@@ -28,6 +27,8 @@
 #include <KDE/KLocale>
 #include <KDE/KStandardDirs>
 #include <KDE/KStandardAction>
+#include <KDE/KConfig>
+#include <KDE/KConfigGroup>
 
 static QHash<QString,QString> s_stdActionCaptions;
 
@@ -78,9 +79,9 @@
 }
 
 bool
-ComponentAction::load(const QDomElement &docElem)
+ComponentAction::load(KConfigGroup *actionGroup)
 {
-  QString _type = docElem.attribute("type");
+  QString _type = actionGroup->readEntry("Type", QString() );
   if (_type == "immutable")
     type = ActImmutable;
   else if (_type == "action restriction")
@@ -104,20 +105,15 @@
     return false;
   }
 
-  file = docElem.attribute("file");
-  group = docElem.attribute("group");
-  key = docElem.attribute("key");
-  defaultValue = (docElem.attribute("default").toLower() == "true");
-
-  QDomNode n = docElem.firstChild();
-  while( !n.isNull() )
-  {
-    QDomElement e = n.toElement(); // try to convert the node to an element.
-
-    if (e.tagName() == "caption")
-      caption = expand(i18n(e.text().simplified().toUtf8()));
-    else if (e.tagName() == "description")
-      description = expand(i18n(e.text().simplified().toUtf8()));
+  file = actionGroup->readEntry("File", QString() );
+  group = actionGroup->readEntry("Group", QString() );
+  key = actionGroup->readEntry("Key", QString() );
+  defaultValue = (actionGroup->readEntry("Default", QString() ).toLower() == \
"true"); +  caption = expand( actionGroup->readEntry("Name", QString() ) );
+  description = expand( actionGroup->readEntry("Description", QString() ) );
+  version = expand( actionGroup->readEntry("Version", QString() ) );
+  
+      /* does anything use this?!
     else if (e.tagName() == "action")
     {
       ComponentAction *subAction = new ComponentAction;
@@ -130,10 +126,7 @@
         delete subAction;
       }
     }
-
-    n = n.nextSibling();
-  }
-
+*/
   return true;
 }
 
@@ -147,99 +140,62 @@
     qDeleteAll(actions);
 }
 
-bool ComponentData::loadActions(const QDomElement &docElem)
+bool ComponentData::loadActions(KConfig *groupFile )
 {
-  QDomNode n = docElem.firstChild();
-  while( !n.isNull() )
+  foreach( QString groupName, groupFile->groupList() )
   {
-    QDomElement e = n.toElement(); // try to convert the node to an element.
-
-    if (e.tagName() != "action")
-      return false;
-
-    ComponentAction *action = new ComponentAction;
-    if (action->load(e))
+    if( groupName.startsWith("Action-") )
     {
-      actions.append(action);
+      KConfigGroup actionGroup = groupFile->group(groupName);
+      ComponentAction *action = new ComponentAction;
+      if (action->load(&actionGroup) )
+      {
+	actions.append(action);
+      }
+      else
+      {
+	delete action;
+      }
+      
     }
-    else
-    {
-      delete action;
-    }
-    n = n.nextSibling();
   }
   return true;
 }
 
 void
-ComponentExecData::load(const QDomElement &e)
+ComponentExecData::load(KConfigGroup *actionGroup)
 {
-   exec = e.attribute("binary");
-   dbus = e.attribute("dbus");
-   options = e.attribute("options").split(',');
-   args = e.attribute("args").split(',');
+   exec = actionGroup->readEntry("Binary", QString() );
+   dbus = actionGroup->readEntry("DBus", QString() );
+   options = actionGroup->readEntry("Options", QString() ).split(',');
+   args = actionGroup->readEntry("Args", QString() ).split(',');
 }
 
 void
-ComponentData::loadSetup(const QDomElement &docElem)
+ComponentData::loadSetup(KConfigGroup *setupGroup)
 {
-  QDomNode n = docElem.firstChild();
-  while( !n.isNull() )
-  {
-    QDomElement e = n.toElement(); // try to convert the node to an element.
-
-    if (e.tagName() == "mutable")
-    {
-      QString f = e.attribute("file");
-      if (!f.isEmpty())
-        mutableFiles.append(f);
-    }
-    else if (e.tagName() == "ignore")
-    {
-      QString f = e.attribute("file");
-      if (!f.isEmpty())
-        ignoreFiles.append(f);
-    }
-
-    n = n.nextSibling();
-  }
+  mutableFiles = setupGroup->readEntry("Mutable", QString() ).split(',');
+  ignoreFiles = setupGroup->readEntry("Ignore", QString() ).split(',');
 }
 
-bool ComponentData::load(const QDomElement &docElem)
+bool ComponentData::load(KConfig *groupFile)
 {
-  id = docElem.attribute("name");
-  icon = docElem.attribute("icon");
-  if (id.isEmpty())
-    return false;
-  QDomNode n = docElem.firstChild();
-  while( !n.isNull() )
-  {
-    QDomElement e = n.toElement(); // try to convert the node to an element.
+  id = groupFile->name();
+  
+  KConfigGroup groupInfo = groupFile->group("Group");
+  icon = groupInfo.readEntry("Icon", "ackage-x-generic");
+  caption = groupInfo.readEntry("Name", QString() );
+  description= groupInfo.readEntry("Description", QString() );
 
-    if (e.tagName() == "caption")
-    {
-       caption = i18n(e.text().simplified().toUtf8());
-    }
-    else if (e.tagName() == "description")
-    {
-       description = i18n(e.text().simplified().toUtf8());
-    }
-    else if (e.tagName() == "actions")
-    {
-       loadActions(e);
-    }
-    else if (e.tagName() == "setup")
-    {
-       setup.load(e);
-       loadSetup(e);
-    }
-    else if (e.tagName() == "preview")
-    {
-       preview.load(e);
-    }
+  KConfigGroup groupSetup = groupFile->group("Setup");
+  
+  KConfigGroup groupPreview = groupFile->group("Preview");
 
-    n = n.nextSibling();
-  }
+  setup.load( &groupSetup );
+  loadSetup( &groupSetup );
+  preview.load( &groupPreview );
+  loadActions( groupFile );
+  
   return true;
 }
 
@@ -254,54 +210,19 @@
 
 bool KioskData::load()
 {
-  QString filename = KStandardDirs::locate("appdata", "kiosk_data.xml");
-  if (filename.isEmpty())
-  {
-    m_errorMsg = i18n("<qt>Could not find <b>kiosk_data.xml</b></qt>");
-    return false;
-  }
-
-  QDomDocument doc;
-  QFile file( filename );
-  if ( !file.open( QIODevice::ReadOnly ) )
-  {
-    m_errorMsg = i18n("<qt>Could not open <b>%1</b></qt>",filename);
-    return false;
-  }
-
-  QString errorMsg;
-  int errorRow;
-  int errorCol;
-  if ( !doc.setContent( &file, &errorMsg, &errorRow, &errorCol ) )
-  {
-    m_errorMsg = i18n("<qt>Syntax error in <b>%1</b><br>Line %3, column %4: \
                %2</qt>",filename, errorMsg,errorRow,errorCol);
-    file.close();
-    return false;
-  }
-  file.close();
-
-  QDomElement docElem = doc.documentElement();
-  QDomNode n = docElem.firstChild();
-  while( !n.isNull() )
-  {
-    QDomElement e = n.toElement(); // try to convert the node to an element.
-
-    if (e.tagName() == "group")
+  foreach( QString groupFile, KGlobal::dirs()->findAllResources("data", \
"kiosktool/*.kisok", KStandardDirs::NoDuplicates) ) +  {   
+    KConfig groupConfigFile(groupFile, KConfig::SimpleConfig);
+    ComponentData *componentData = new ComponentData;
+    if (componentData->load(&groupConfigFile))
     {
-      ComponentData *componentData = new ComponentData;
-      if (componentData->load(e))
-      {
-         m_componentData.insert(componentData->id, componentData);
-         m_componentList.append(componentData->id);
-      }
-      else
-      {
-         delete componentData;
-      }
+	m_componentData.insert(componentData->id, componentData);
+	m_componentList.append(componentData->id);
     }
-
-    n = n.nextSibling();
+    else
+    {
+	delete componentData;
+    }      
   }
-
   return true;
 }
--- trunk/extragear/sysadmin/kiosktool/kioskdata.h #933755:933756
@@ -24,14 +24,15 @@
 #include <QList>
 #include <QHash>
 
-class  QDomElement;
+class KConfig;
+class KConfigGroup;
 
 class ComponentAction
 {
 public:
    ComponentAction();
    ~ComponentAction();
-   bool load(const QDomElement &docElem);
+   bool load(KConfigGroup *);
 
 private:
    QString expand(const QString &);
@@ -46,13 +47,14 @@
    QString key;
    QList<ComponentAction*> subActions;
    bool defaultValue;
+   QString version;
 
 
 };
 class ComponentExecData
 {
 public:
-   void load(const QDomElement &docElem);
+   void load(KConfigGroup *group);
    bool hasOption(const QString &option) { return options.contains(option); }
 public:
    QString exec;
@@ -66,11 +68,11 @@
 public:
    ComponentData();
    ~ComponentData();
-   bool load(const QDomElement &docElem);
-   bool loadActions(const QDomElement &docElem);
+   bool load(KConfig *group);
+   bool loadActions(KConfig *group);
 
 protected:
-   void loadSetup(const QDomElement &docElem);
+   void loadSetup(KConfigGroup *group);
 
 public:
    QString id;
--- trunk/extragear/sysadmin/kiosktool/kioskrun.cpp #933755:933756
@@ -66,8 +66,6 @@
    m_noRestrictions = false;
    m_forceSycocaUpdate = false;
    s_self = this;
-   //m_saveConfigCache.setAutoDelete(true);
-   //m_immutableStatusCache.setAutoDelete(true);
    m_homeDir = QDir::homePath()+"/.kde-test";
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    m_kderc = args->getOption("kderc");
--- trunk/extragear/sysadmin/kiosktool/menueditComponent.cpp #933755:933756
@@ -80,6 +80,9 @@
 {
    KSaveFile saveFile(fileName);
 
+   if( !saveFile.open(QIODevice::WriteOnly ) )
+      return false;
+
    saveFile.write( doc.toString().toUtf8() );
 
    if (!saveFile.finalize())
--- trunk/extragear/sysadmin/kiosktool/panelComponent.cpp #933755:933756
@@ -25,7 +25,6 @@
 
 #include <kdebug.h>
 #include <kmimetype.h>
-#include <ksavefile.h>
 #include <ksimpleconfig.h>
 #include <kstandarddirs.h>
 #include <kurl.h>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic