Anonymous avatar Anonymous committed 4442d41

jl155 #i111592# online update again

Comments (0)

Files changed (3)

desktop/source/deployment/gui/dp_gui_updatedialog.cxx

 }
     
 
+//Currently the user does not see shared extensions if there are user extensions
+//with the same identifier are installed. The update dialog does also NOT
+//display an update for user and shared (both with the same id). It just shows
+//one update. If it is installed for user and shared depends in most cases on
+//having an extension with that id installed in the respective repository.
+//That is, even if only one update is displayed it may be applied two times, for
+//user and shared extension.
+//
+//For
+//example, there is a shared extension and no user extension. Then the update is
+//only installed in the shared repository and not in the user repository,
+//because there was no user extension. This requires, however, that the user can
+//write to the shared folder of the installation. If has no write access, then
+//the update is installed in the user repository.
+
+//If the user has a user extension but no shared extension, then the update will
+//only be installed in the user repository and not in the shared repository,
+//because there is no extension installed.
+
+//Updates do not only come from online repositories but also extensions in the
+//bundled and shared repositories are uses as possible updates. For example,
+//there are a bundled and a user extension with the same identifier and the
+//bundled extension has a higher version. The update dialog will then use the
+//bundled extension as update for the user extension.
+
+//In case one update requires another extension, which is not currently
+//installed, then the required extension will be installed in the shared
+//repository if the depending extension is in the same repository. Note, that
+//the required extension is a "first-installation" and not update regarding this
+//repository. This is done even if the required extension is already
+//installed in the user repository. This would satisfy the dependency but not
+//necessarily for other users who may not have this user extension.
+
+//This is different if a user extension is updated. If the user extension
+//requires an extension which is installed in the shared repository or is an
+//update for the same, then the required extension is NOT installed in the user
+//repository.
+
+//Tere can be the case that there is a local update AND a online update with a
+//better version but unsatisfied dependencies. Then the local update would be
+//used and when checking the next time, the disabled online update would be
+//displayd
+
+//The information what extensions are to be updated is contained in
+//m_vExtensionList. It contains exactly one extension for one particular
+//identifier. That is, it does not reflect necessarily the extension which was
+//selected by the user. The extensions in m_vExtensionList are those which have
+//the highest versions among the group of extensions with the same identifiers
+//from the bundled, shared and user repositoriy. The idea is, that newer
+//extensions may contain more recent update information, provided that they
+//provide their own update information.
 void UpdateDialog::Thread::execute()
 {
     {
     //extension which is required by an update.
     //An entry can also be a "disabled update" because there are unsatisfied
     //dependencies.
+    //That is, every entry must be displayed in the dialog
     for (CIT ii = vecUpdateData.begin(); ii != vecUpdateData.end(); ii++)
     {
         UpdateData updateData = *ii;
             continue;
         }
         //If there is no online update or there is one but the dependency check
-        //failed, then sOnlineVersion is an empty string.        
-        //Determine if the update is installed in the user repository and from where
-        //is is taken, that is from the online, shared or bundled repository.
-        // dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
-        //     bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
-        // dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
-        //     bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
-        int highestUser = dp_misc::determineHighestVersion(
-            sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
-        int highestShared = dp_misc::determineHighestVersion(
-            ::rtl::OUString(), sVersionShared, sVersionBundled, sOnlineVersion);
-        
-        if (highestUser == 1) // source is SHARED
+        //failed, then sOnlineVersion is an empty string. Installed extensions
+        //have satisfied dependencies, otherwise they are inoperative and would
+        //not be returned by getExtensionsWithSameIdentifier.        
+        dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+            bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled, sOnlineVersion);
+        dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+            bSharedReadOnly, sVersionShared, sVersionBundled, sOnlineVersion);
+
+        if (sourceUser == dp_misc::UPDATE_SOURCE_SHARED)
         {
             //The local update source is always the same or better than
             //the online update and has satisfied dependendencies. Otherwise
             updateData.aUpdateSource = extensions[1];
             updateData.updateVersion = extensions[1]->getVersion();
         }
-        else if (highestUser == 2) //source is BUNDLED
+        else if (sourceUser == dp_misc::UPDATE_SOURCE_BUNDLED) 
         {
             updateData.unsatisfiedDependencies.clear();
             updateData.requiredUpdates.clear();
             updateData.updateVersion = extensions[2]->getVersion();
         }
         
-        if (highestShared == 2) //source is BUNDLED
+        if (sourceShared == dp_misc::UPDATE_SOURCE_BUNDLED) 
         {
             updateData.unsatisfiedDependencies.clear();
             updateData.requiredUpdates.clear();
-            //          updateData.bIsShared = true;
             updateData.aUpdateSource = extensions[2];
             updateData.updateVersion = extensions[2]->getVersion();
         }
 
-        update(updateData);
+        if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
+        {
+            updateData.bIsShared = false;
+            update(updateData);
+        }
+        if (sourceShared != dp_misc::UPDATE_SOURCE_NONE)
+        {
+            updateData.bIsShared = true;
+            update(updateData);
+        }
 
-        // if (sourceShared != dp_misc::UPDATE_SOURCE_NONE ||
-        //     sourceUser != dp_misc::UPDATE_SOURCE_NONE)
-        // {
-        //     update(updateData);
-        // }
-        // else if(sourceShared == dp_misc::UPDATE_SOURCE_NONE &&
-        //         sourceUser == dp_misc::UPDATE_SOURCE_NONE
-        //         && updateData.unsatisfiedDependencies.size())
-        // {    
-        //     //Even show the possible update if it has unsatisfied dependencies
-        //     //which may only happen with online updates.
-        //     //It must have a greater version than the installed one
-        //     dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
-        //         bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled,
-        //         updateData.onlineVersion);
-        //     dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
-        //         bSharedReadOnly, sVersionShared, sVersionBundled, updateData.onlineVersion);
-        //     if (sourceUser == dp_misc::UPDATE_SOURCE_ONLINE
-        //         || sourceShared == dp_misc::UPDATE_SOURCE_ONLINE)
-        //         update(updateData);
-        // }
+        //check if we can display an update with unsatisfied dependencies
+        if(sourceUser == dp_misc::UPDATE_SOURCE_NONE
+           && updateData.unsatisfiedDependencies.size())
+        {
+            dp_misc::UPDATE_SOURCE sourceUser = dp_misc::isUpdateUserExtension(
+                bSharedReadOnly, sVersionUser, sVersionShared, sVersionBundled,
+                updateData.onlineVersion);
+            if (sourceUser != dp_misc::UPDATE_SOURCE_NONE)
+            {
+                updateData.bIsShared = false;
+                update(updateData);
+            }
+        }
 
-        //ToDo: handle the case that there is a local update AND a online update
-        //with a better version but unsatisfied dependencies
+        if(sourceShared == dp_misc::UPDATE_SOURCE_NONE
+           && updateData.unsatisfiedDependencies.size())
+        {
+            dp_misc::UPDATE_SOURCE sourceShared = dp_misc::isUpdateSharedExtension(
+                bSharedReadOnly, sVersionShared, sVersionBundled, updateData.onlineVersion);
+            if (sourceShared != dp_misc::UPDATE_SOURCE_ONLINE)
+            {
+                updateData.bIsShared = true;
+                update(updateData);
+            }
+        }
     }
 
     

desktop/source/deployment/inc/dp_update.hxx

     ::com::sun::star::deployment::XPackage> > const & seqExtensionsWithSameId);
 
 
-// struct UpdateInfo
-// {
-//     UpdateInfo( ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & ext);
-//     UpdateInfo();
-//     ::com::sun::star::uno::Reference<
-//         ::com::sun::star::deployment::XPackage> extension;
-// //version of the update 
-//     ::rtl::OUString version;
-//     ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNode > info;
-// };
-
 //typedef std::hash_map< ::rtl::OUString, UpdateInfo, ::rtl::OUStringHash > UpdateInfoMap;
 typedef std::hash_map< ::rtl::OUString, ::com::sun::star::uno::Reference<
     ::com::sun::star::xml::dom::XNode>, ::rtl::OUStringHash > UpdateInfoMap;

desktop/source/deployment/misc/dp_update.cxx

     }
     else
     {
-        // if (userVersion.getLength())
-        // {
+        if (userVersion.getLength())
+        {
             int index = determineHighestVersion(
                 userVersion, sharedVersion, bundledVersion, onlineVersion);
             if (index == 1)
                 retVal = UPDATE_SOURCE_BUNDLED;
             else if (index == 3)
                 retVal = UPDATE_SOURCE_ONLINE;
-//        }
+        }
     }
         
     return retVal;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.