[Title]INST : distribution changes, re-install
authorshihyun.kim <shihyun.kim@samsung.com>
Fri, 28 Dec 2012 03:39:08 +0000 (12:39 +0900)
committershihyun.kim <shihyun.kim@samsung.com>
Fri, 28 Dec 2012 03:39:08 +0000 (12:39 +0900)
[Desc.]
* If you are updating from other distribution, remove all packages and re-install.
[Issue]

InstallManager_java/src/org/tizen/installmanager/core/Config.java
InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java
InstallManager_java/src/org/tizen/installmanager/lib/IIMProgressMonitor.java
InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java
InstallManager_java/src/org/tizen/installmanager/pkg/model/ConfigFile.java
InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java
InstallManager_java/src/org/tizen/installmanager/ui/page/InstallingPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/PackageListPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/UninstallingPage.java
InstallManager_java/src/org/tizen/installmanager/ui/page/ViewController.java

index 134ea61..1e49b12 100644 (file)
@@ -467,14 +467,6 @@ public class Config {
        public void setServerType(ServerType serverType) {
                this.serverType = serverType;
        }
-       
-       /**
-        * Set type of repository.
-        * @param type
-        */
-       public void setRepositoryType(String type) {
-               mConfigFile.setDistribution(type);
-       }
 
        /**
         * Create configuration directory.
@@ -609,4 +601,16 @@ public class Config {
                
                return config;
        }
+       
+       /**
+        * @return if true, distribution is different from installed distribution.
+        */
+       public boolean isDistributionChanged() {
+               String installedDistribution = mConfigFile.getInstalledDistribution();
+               if (installedDistribution.equalsIgnoreCase(mConfigFile.getDistribution())) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
 }
index ba61493..32aba7e 100644 (file)
@@ -84,6 +84,8 @@ public class InstallManager {
        private File makeShortCutFile = null;
        private File removeShortCutFile = null;
 
+       private static String REMOVE_ALL_PACKAGES = "Remove all packages...";
+       private static String REMOVE_ALL_SDK_FILES = "Remove all SDK files...";
        private InstallManager() {
        }
 
@@ -424,7 +426,7 @@ public class InstallManager {
                for (Package pkg : downloadPkgSet) {
 
                        if (monitor != null) {
-                               monitor.setPackageName(pkg.getPackageName());
+                               monitor.setProgressTitle(pkg.getPackageName());
                        }
 
                        if (monitor != null && monitor.isCanceled()) {
@@ -594,7 +596,7 @@ public class InstallManager {
                Log.log("Install package '" + pkg + "'");
 
                if (monitor != null) {
-                       monitor.setPackageName(pkg.getPackageName());
+                       monitor.setProgressTitle(pkg.getPackageName());
                }
 
                Installer installer = new Installer();
@@ -657,29 +659,34 @@ public class InstallManager {
 
                // save target directory
                initializeTargetDir(targetDir);
+               
+               //if distribution is changed, remove all packages and install.
+               if (mConfig.isDistributionChanged()) {
+                       removeAllPackages(monitor);
+               } else {
+                       // remove missing packages
+                       removeMissingPackages(monitor);
 
-               // remove missing packages
-               removeMissingPackages(monitor);
-
-               // remove conflict packages
-               if (!removeConflictPackages(installablePackages, monitor)) {
-                       Log.err("Cannot remove conflict package");
-                       throw new IMFatalException(
-                                       ErrorCode.CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES);
-               }
+                       // remove conflict packages
+                       if (!removeConflictPackages(installablePackages, monitor)) {
+                               Log.err("Cannot remove conflict package");
+                               throw new IMFatalException(
+                                               ErrorCode.CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES);
+                       }
 
-               boolean result = false;
-               //If Options.snapshot is true, remove installed packages that differernt version from installable packages.
-               if (Options.snapshot) {
-                       result = removeDifferentVersionPackages(installablePackages, monitor);
-               } else {
-                       result = removeUpdatablePackages(installablePackages, monitor);
-               }
-               
-               if (!result) {
-                       Log.err("Cannot remove updatable package");
-                       throw new IMFatalException(
-                                       ErrorCode.CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES);
+                       boolean result = false;
+                       //If Options.snapshot is true, remove installed packages that differernt version from installable packages.
+                       if (Options.snapshot) {
+                               result = removeDifferentVersionPackages(installablePackages, monitor);
+                       } else {
+                               result = removeUpdatablePackages(installablePackages, monitor);
+                       }
+                       
+                       if (!result) {
+                               Log.err("Cannot remove updatable package");
+                               throw new IMFatalException(
+                                               ErrorCode.CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES);
+                       }
                }
 
                //start installation
@@ -742,7 +749,7 @@ public class InstallManager {
                Log.log("Remove missing packages => " + missingPackages);
 
                if (monitor != null) {
-                       monitor.setPackageName("Remove Missing Packages");
+                       monitor.setProgressTitle("Remove Missing Packages");
                }
 
                for (Package pkg : missingPackages) {
@@ -761,7 +768,7 @@ public class InstallManager {
                Log.log("Remove conflict packages => " + conflictPackages);
 
                if (monitor != null) {
-                       monitor.setPackageName("Remove Conflict Packages");
+                       monitor.setProgressTitle("Remove Conflict Packages");
                }
 
                return remove(conflictPackages);
@@ -775,7 +782,7 @@ public class InstallManager {
                Log.log("Remove packages in snapshot => " + updatablePackages);
 
                if (monitor != null) {
-                       monitor.setPackageName("Remove updatable Packages");
+                       monitor.setProgressTitle("Remove updatable Packages");
                }
 
                return remove(updatablePackages);
@@ -788,7 +795,7 @@ public class InstallManager {
                Log.log("Remove updatable packages => " + updatablePackages);
 
                if (monitor != null) {
-                       monitor.setPackageName("Remove updatable Packages");
+                       monitor.setProgressTitle("Remove updatable Packages");
                }
 
                return remove(updatablePackages);
@@ -1119,7 +1126,7 @@ public class InstallManager {
                }
 
                if (monitor != null) {
-                       monitor.setPackageName(pkg.getPackageName());
+                       monitor.setProgressTitle(pkg.getPackageName());
                }
 
                Installer installer = new Installer();
@@ -1186,7 +1193,7 @@ public class InstallManager {
                                removeAll(monitor);
                        } else {
                                // not exist to remove
-                               removeSDK();
+                               removeSDK(monitor);
                        }
                }
 
@@ -1202,6 +1209,17 @@ public class InstallManager {
        public void removeAll(IIMProgressMonitor monitor) {
                Log.log("InstallManager.removeAll()");
 
+               removeAllPackages(monitor);
+               removeSDK(monitor);
+       }
+       
+       private void removeAllPackages(IIMProgressMonitor monitor) {
+               Log.log("Remove all packages.");
+               
+               if (monitor != null) {
+                       monitor.setProgressTitle(REMOVE_ALL_PACKAGES);
+               }
+               
                PackageSet removablePackages = packageManager.getInstalledPackages();
 
                for (Package pkg : removablePackages) {
@@ -1209,15 +1227,17 @@ public class InstallManager {
                                Log.err("InstallManager.removeAll remove fail => " + pkg);
                        }
                }
-
-               removeSDK();
        }
 
        /**
         * Remove All of TizenSDK files.
         */
-       public void removeSDK() {
+       public void removeSDK(IIMProgressMonitor monitor) {
                Log.log("InstallManager removeSDK start");
+               
+               if (monitor != null) {
+                       monitor.setProgressTitle(REMOVE_ALL_SDK_FILES);
+               }
 
                removeInstallManager();
                removeChangeLog();
index 659ef24..75b87ec 100644 (file)
@@ -41,7 +41,7 @@ public interface IIMProgressMonitor extends IProgressMonitor{
         * set name of package.
         * @param name
         */
-       public void setPackageName(String name);
+       public void setProgressTitle(String name);
        /**
         * set file name while installing or uninstalling
         * @param name
index a4bd46a..9f2a29a 100644 (file)
@@ -768,9 +768,15 @@ public abstract class PackageManager {
         * @return packages to newly install in update process by the selected meta packages
         */
        public PackageSet getInstallablePackages(PackageSet selectedMetas) {
-               PackageSet result = getResultPackagesAfterUpdate(selectedMetas);
-               PackageSet installablePkgs = diffPackageWithVersion(result, installedPackages);
-               return installablePkgs;
+               PackageSet installablePackages = null;
+               if (Config.getInstance().isDistributionChanged()) {
+                       installablePackages = dep(selectedMetas, State.INSTALL);
+               } else {
+                       PackageSet result = getResultPackagesAfterUpdate(selectedMetas);
+                       installablePackages = diffPackageWithVersion(result, installedPackages);
+               }
+               
+               return installablePackages;
        }
        
        /**
index 475a072..35d8496 100644 (file)
@@ -61,6 +61,7 @@ public class ConfigFile {
        private static final String FIELD_PROXY_SERVER = "Proxy-Server";
        private static final String FIELD_PROXY_PORT = "Proxy-Port";
 
+       private String installedDistribution = "";
        //Set of property
        private Properties mProperties;
        //path of config file.
@@ -74,6 +75,8 @@ public class ConfigFile {
                } else {
                        Log.log("Success to load config file in this path : " + confPath);
                }
+               
+               installedDistribution = getDistribution();
        }
 
        /**
@@ -89,6 +92,13 @@ public class ConfigFile {
        public String getDistribution() {
                return getValue(FIELD_Distribution);
        }
+       
+       /**
+        * @return Distribution of installed sdk.
+        */
+       public String getInstalledDistribution() {
+               return installedDistribution;
+       }
 
        /**
         * @return Repository of installmanager to update installmanager's binary
index b9741d0..88f4fc3 100644 (file)
@@ -328,14 +328,9 @@ public class InstallManagerWindow extends ApplicationWindow {
                                        addExtraButton.setVisible(false);
                                        btnSettings.setVisible(false);
                                        if (compositeWelcomePage.getSelectedRadioButton() == RADIO_ACTION.INSTALL) {
-//                                             if (!ErrorController.checkInstallationSuccess()) {
-//                                                     return;
-//                                             }
-                                               
                                                btnNext.setEnabled(compositeLicensePage.getAcceptButton()
                                                                                                                                .getSelection());
-                                               if (controller.existRemovablePackage()) // Update case
-                                               {
+                                               if (!controller.isNewInstallation()) {// Update case
                                                        compositeUpdatableListPage.loadPage(controller);
                                                        btnBack.setVisible(true);
                                                        addExtraButton.setVisible(true);
index 3cf3ced..08c8c37 100644 (file)
@@ -28,7 +28,6 @@
 
 package org.tizen.installmanager.ui.page;
 
-import java.awt.Desktop;
 import java.text.DecimalFormat;
 import java.util.List;
 
@@ -386,7 +385,7 @@ public class InstallingPage extends PageTemplate {
                }
 
                @Override
-               public void setPackageName(String name) {
+               public void setProgressTitle(String name) {
                        mProgressTitle = name;
                }
 
index 0183697..c9f7932 100644 (file)
@@ -373,19 +373,9 @@ public abstract class PackageListPage extends PageTemplate {
                }
 
                for (Package pkg : packageSet) {
-                       if (!pkg.isRootMeta() && !pkg.isPartnerMeta() && !pkg.isExtraMeta() && !pkg.isPublicMeta()) {
+                       if (!pkg.isMeta()) {
                                continue;
                        }
-
-                       if (!Options.partnerSdk) { // Public SDK case
-                               if (pkg.isPartnerMeta()) {
-                                       continue;
-                               }
-                       } else { // Partner SDK case
-                               if (pkg.isPublicMeta()) {
-                                       continue;
-                               }
-                       }
                        
                        String packageName = pkg.getPackageName();
                        Package installedPackage = viewController.getInstalledPackage(packageName);
@@ -443,12 +433,16 @@ public abstract class PackageListPage extends PageTemplate {
                items.remove(item);
        }
        private InstallState getState(Package pkg) {
-               if (viewController.getInstallableMetaPackageList().contains(pkg)) {
+               if (Config.getInstance().isDistributionChanged()) {
                        return InstallState.INSTALL;
-               } else if (viewController.getUpdatableMetapackageList().contains(pkg)) {
-                       return InstallState.UPDATE;
                } else {
-                       return InstallState.UNINSTALL;
+                       if (viewController.getInstallableMetaPackageList().contains(pkg)) {
+                               return InstallState.INSTALL;
+                       } else if (viewController.getUpdatableMetapackageList().contains(pkg)) {
+                               return InstallState.UPDATE;
+                       } else {
+                               return InstallState.UNINSTALL;
+                       }
                }
        }
 
index 2e9787f..4b0baf4 100644 (file)
@@ -278,7 +278,7 @@ public class UninstallingPage extends PageTemplate {
                }
 
                @Override
-               public void setPackageName(String name) {
+               public void setProgressTitle(String name) {
                        mProgressTitle = name;
                }
 
index 9ea8395..a34740a 100644 (file)
@@ -213,6 +213,19 @@ public class ViewController {
                        return packageManager.existInstalledPackages();
                }
        }
+       
+       /**
+        * 
+        */
+       public boolean isNewInstallation() {
+               Config config = Config.getInstance();
+               
+               if (config.isDistributionChanged()) {
+                       return true;
+               } else {
+                       return !packageManager.existInstalledPackages();
+               }
+       }
 
        /**
         * Start to install and update.