Fix Manifest generation step 14/33914/1
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 16 Jan 2015 10:21:17 +0000 (11:21 +0100)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 16 Jan 2015 10:21:17 +0000 (11:21 +0100)
-> Align Privileges section generation with the specs
-> Add robustness when there is neither svc app information nor ui app information

Change-Id: I76de58d65a67b508c7777d0b964c00a4b74fc501
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
src/common/step/step_generate_xml.cc

index b5037ff..7779f2b 100644 (file)
@@ -40,8 +40,17 @@ int StepGenerateXml::process(ContextInstaller* data) {
   boost::system::error_code error;
   uiapplication_x* ui = data->manifest_data()->uiapplication;
   serviceapplication_x* svc = data->manifest_data()->serviceapplication;
-  appcontrol_x* appc_ui = ui->appcontrol;
-  appcontrol_x* appc_svc = svc->appcontrol;
+  if ((!ui) && (!svc)) {
+    ERR("There is neither UI applications nor Services applications described!\n");
+    return APPINST_R_ERROR;
+  }
+  appcontrol_x* appc_ui = nullptr;
+  appcontrol_x* appc_svc = nullptr;
+  if (ui)
+    appc_ui = ui->appcontrol;
+  if (svc)
+    appc_svc = svc->appcontrol;
+
   privileges_x* pvlg =  data->manifest_data()->privileges;
 
   fs::path default_icon(
@@ -239,25 +248,22 @@ int StepGenerateXml::process(ContextInstaller* data) {
   // add privilege element
   for (;pvlg != nullptr; pvlg = pvlg->next) {
     privilege_x* pv = pvlg->privilege;
-    xmlTextWriterStartElement(writer, BAD_CAST "privilege");
 
     for (;pv != nullptr; pv = pv->next) {
-       xmlTextWriterWriteAttribute(writer, BAD_CAST "text",
+    xmlTextWriterStartElement(writer, BAD_CAST "privilege");
+    xmlTextWriterWriteAttribute(writer, BAD_CAST "name",
                                       BAD_CAST pv->text);
-
-      xmlTextWriterEndElement(writer);
-
       if (!pv->next)
         break;
-        xmlTextWriterEndElement(writer);
+
+      xmlTextWriterEndElement(writer);  // </privileges> tag
       }
     if (!pvlg->next)
       break;
-    xmlTextWriterEndElement(writer);
   }
 
 
-  xmlTextWriterEndElement(writer);
+  xmlTextWriterEndElement(writer); // </manifest> tag
 
   xmlTextWriterEndDocument(writer);