fix coding style in few files 49/32749/2
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 23 Dec 2014 11:09:03 +0000 (12:09 +0100)
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 23 Dec 2014 14:29:53 +0000 (15:29 +0100)
  * app_installer.h
  * app_installer.cc
  * step.h
  * wgt_backend.cc

Change-Id: Ib160a18be703a04e022c4a55a115d3165845fcf3
Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
common/include/app_installer.h
common/include/step.h
common/src/app_installer.cc
wgt/src/wgt_backend.cc

index 2f244b7..d2c6266 100644 (file)
@@ -1,18 +1,23 @@
-#ifndef __APPINSTALLER_H__
-#define __APPINSTALLER_H__
-#include <context_installer.h>
-#include <step.h>
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+
+#ifndef COMMON_INCLUDE_APP_INSTALLER_H_
+#define COMMON_INCLUDE_APP_INSTALLER_H_
+
 #include <list>
 
+#include "include/step.h"
+
 class AppInstaller {
+ private:
+  std::list<Step*> ListStep;
+  ContextInstaller* ctx_;
 
-protected:
-       std::list<Step*> ListStep;
-       ContextInstaller* ctx_;
-public:
-       AppInstaller(int request, const char * file, const char* pkgid);
-       ~AppInstaller();
-       int AddStep(Step *step);
-       int Run();
+ public:
+  AppInstaller(int request, const char* file, const char* pkgid);
+  ~AppInstaller();
+
+  int AddStep(Step* step);
+  int Run();
 };
-#endif
+
+#endif  // COMMON_INCLUDE_APP_INSTALLER_H_
index 30ea8c9..0a26a79 100644 (file)
@@ -1,3 +1,5 @@
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+
 /*
   A step is made of 3 functions (that can be defined or NULL)
   and one data pointer.
   Otherwise, the returned code should be set to -1 with errno set
   to some meaningful value.
 */
-#ifndef __STEP_H__
-#define __STEP_H__
-#include <context_installer.h>
+#ifndef COMMON_INCLUDE_STEP_H_
+#define COMMON_INCLUDE_STEP_H_
 
-class Step {
-public:
-       virtual int process(ContextInstaller*)=0;
-       virtual int undo(ContextInstaller*)=0;
-       virtual int clean(ContextInstaller*)=0;
+#include "include/context_installer.h"
 
+class Step {
+ public:
+  virtual int process(ContextInstaller* context)=0;
+  virtual int undo(ContextInstaller* context)=0;
+  virtual int clean(ContextInstaller* context)=0;
 };
-#endif
+
+#endif  // COMMON_INCLUDE_STEP_H_
index a0796e0..8f51e96 100644 (file)
@@ -1,56 +1,60 @@
-#include <app_installer.h>
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+
 #include <iostream>
 #include <cstdio>
 
-AppInstaller::AppInstaller(int request, const char * file, const char* pkgid) {
+#include "include/app_installer.h"
+#include "include/context_installer.h"
+
+AppInstaller::AppInstaller(int request, const char* file, const char* pkgid) {
   ctx_ = new ContextInstaller();
   ctx_->set_request_type(request);
   ctx_->set_pkgid(pkgid);
   ctx_->set_file_path(file);
 }
 
-AppInstaller::~AppInstaller() { delete ctx_; }
+AppInstaller::~AppInstaller() {  delete ctx_; }
 
 
 int AppInstaller::AddStep(Step *step) {
-       try {
-               ListStep.push_back(step);
-       } catch (int e) {
-               return -1;
-       }
-       return 0;
+  try {
+    ListStep.push_back(step);
+  } catch (int e) {
+    return -1;
+  }
+  return 0;
 }
 
 int AppInstaller::Run() {
-       std::list<Step *>::iterator it (ListStep.begin());
-       std::list<Step *>::iterator itStart(ListStep.begin());
-       std::list<Step *>::iterator itEnd(ListStep.end());
-
-       int ret = 0;
-       for(;it!=itEnd;++it) {
-               if((*it)->process(ctx_) != APPINST_R_OK) {
-                       std::cout << "Error during processing" << std::endl;
-                       ret = -1;
-                       break;
-               }
-       }
-       if (it!=itEnd) {
-                       std::cout << "Faillure occurs" << std::endl;
-               do {
-                       if((*it)->undo(ctx_) != APPINST_R_OK) {
-                               std::cout << "Error during undo operation" << std::endl;
-                               ret = -2;
-                               break;
-                       }
-               } while (it--!=itStart);
-       } else {
-                       while (it--!=itStart) {
-                               if((*it)->clean(ctx_) != APPINST_R_OK) {
-                                       std::cout << "Error during clean operation" << std::endl;
-                                       ret = -3;
-                                       break;
-                               }
-                       }
-       }
-       return ret;
+  std::list<Step *>::iterator it(ListStep.begin());
+  std::list<Step *>::iterator itStart(ListStep.begin());
+  std::list<Step *>::iterator itEnd(ListStep.end());
+
+  int ret = 0;
+  for (; it != itEnd; ++it) {
+    if ((*it)->process(ctx_) != APPINST_R_OK) {
+      std::cout << "Error during processing" << std::endl;
+      ret = -1;
+      break;
+    }
+  }
+  if (it != itEnd) {
+    std::cout << "Faillure occurs" << std::endl;
+    do {
+      if ((*it)->undo(ctx_) != APPINST_R_OK) {
+        std::cout << "Error during undo operation" << std::endl;
+        ret = -2;
+        break;
+      }
+    } while (it-- != itStart);
+  } else {
+    while (it-- != itStart) {
+      if ((*it)->clean(ctx_) != APPINST_R_OK) {
+        std::cout << "Error during clean operation" << std::endl;
+        ret = -3;
+        break;
+      }
+    }
+  }
+  return ret;
 }
index ba6c026..7732144 100644 (file)
@@ -1,51 +1,48 @@
 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
 
-#include <pkgmgr_installer.h>
-#include <cstdio>
-#include <cstdlib>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include <pkgmgr_installer.h>
+
+#include <cstdio>
+#include <cstdlib>
 #include <cstring>
 #include <cerrno>
-#include <cassert>
 #include <memory>
-#include <app_installer.h>
-#include <step_unzip.h>
-#include "step/signature_step.h"
 
-int
-main (int argc, char **argv)
-{
-  int result;
-  AppInstaller *Installer = NULL;
-  step_unzip *step_unpack = NULL;
+#include "include/app_installer.h"
+#include "include/step_unzip.h"
+#include "step/signature_step.h"
 
+int main(int argc, char **argv) {
   /* get request data */
-  pkgmgr_installer *pi = pkgmgr_installer_new ();
+  pkgmgr_installer *pi = pkgmgr_installer_new();
   if (!pi)
     return ENOMEM;
-  result = pkgmgr_installer_receive_request (pi, argc, argv);
-  if (result)
-    {
-      pkgmgr_installer_free (pi);
-      return -result;
-    }
+
+  int result = pkgmgr_installer_receive_request(pi, argc, argv);
+  if (result) {
+    pkgmgr_installer_free(pi);
+    return -result;
+  }
 
   /* treat the request */
-  switch (pkgmgr_installer_get_request_type (pi)) {
+  switch (pkgmgr_installer_get_request_type(pi)) {
     case PKGMGR_REQ_INSTALL: {
-    Installer = new AppInstaller(PKGMGR_REQ_INSTALL, pkgmgr_installer_get_request_info(pi), "");
-    step_unpack = new step_unzip();
-    
-    Installer->AddStep(step_unpack);
+      AppInstaller* Installer = new AppInstaller(PKGMGR_REQ_INSTALL,
+          pkgmgr_installer_get_request_info(pi), "");
+
+      step_unzip* step_unpack = new step_unzip();
+      Installer->AddStep(step_unpack);
 
-    // FIXME: unique_ptr because steps are not freed in installer.
-    std::unique_ptr<common::SignatureStep> signature_step(
-         new common::SignatureStep);
-    Installer->AddStep(signature_step.get());
+      // FIXME: unique_ptr because steps are not freed in installer.
+      std::unique_ptr<common::SignatureStep> signature_step(
+          new common::SignatureStep);
+      Installer->AddStep(signature_step.get());
 
-    Installer->Run();
+      Installer->Run();
       break;
     }
     case PKGMGR_REQ_UNINSTALL: {
@@ -57,6 +54,6 @@ main (int argc, char **argv)
       break;
     }
   }
-  pkgmgr_installer_free (pi);
+  pkgmgr_installer_free(pi);
   return result;
 }