@@ -73,11 +73,13 @@ def setIface(qgisIface):
7373seenPluginGroup = "/Qgis/plugin-seen"
7474
7575
76- # knownRepos: (name, url for QGIS 0.x, url for QGIS 1.x, possible depreciated url, another possible depreciated url)
77- knownRepos = [("Official QGIS Repository" ,"http://spatialserver.net/cgi-bin/pyqgis_plugin.rb" ,"http://pyqgis.org/repo/official" ,"" ,"" ),
78- ("Carson Farmer's Repository" ,"http://www.ftools.ca/cfarmerQgisRepo.xml" ,"http://www.ftools.ca/cfarmerQgisRepo.xml" , "http://www.geog.uvic.ca/spar/carson/cfarmerQgisRepo.xml" ,"http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml" ),
79- ("Borys Jurgiel's Repository" ,"http://bwj.aster.net.pl/qgis-oldapi/plugins.xml" ,"http://bwj.aster.net.pl/qgis/plugins.xml" ,"" ,"" ),
80- ("Faunalia Repository" ,"http://faunalia.it/qgis/plugins.xml" ,"http://faunalia.it/qgis/plugins.xml" ,"http://faunalia.it/qgis/1.x/plugins.xml" ,"" )]
76+ # Repositories: (name, url, possible depreciated url)
77+ oldRepo = ("QGIS 0.x Plugin Repository" , "http://spatialserver.net/cgi-bin/pyqgis_plugin.rb" ,"" )
78+ officialRepo = ("QGIS Official Repository" , "http://pyqgis.org/repo/official" ,"" )
79+ contribRepo = ("QGIS Contributed Repository" , "http://pyqgis.org/repo/contributed" ,"" )
80+ authorRepos = [("Carson Farmer's Repository" , "http://www.ftools.ca/cfarmerQgisRepo.xml" , "http://www.ftools.ca/cfarmerQgisRepo_0.xx.xml" ),
81+ ("Borys Jurgiel's Repository" , "http://bwj.aster.net.pl/qgis/plugins.xml" , "http://bwj.aster.net.pl/qgis-oldapi/plugins.xml" ),
82+ ("Faunalia Repository" , "http://faunalia.it/qgis/plugins.xml" , "http://faunalia.it/qgis/1.x/plugins.xml" )]
8183
8284
8385
@@ -152,15 +154,27 @@ def addKnownRepos(self):
152154 presentURLs = []
153155 for i in self .all ().values ():
154156 presentURLs += [QString (i ["url" ])]
155- for i in knownRepos :
156- if i [QGIS_MAJOR_VER + 1 ] and presentURLs .count (i [QGIS_MAJOR_VER + 1 ]) == 0 :
157- settings = QSettings ()
158- settings .beginGroup (reposGroup )
157+ settings = QSettings ()
158+ settings .beginGroup (reposGroup )
159+ # add the central repositories
160+ if QGIS_MAJOR_VER : # QGIS 1.x
161+ if presentURLs .count (officialRepo [1 ]) == 0 :
162+ settings .setValue (officialRepo [0 ]+ "/url" , QVariant (officialRepo [1 ]))
163+ settings .setValue (officialRepo [0 ]+ "/enabled" , QVariant (True ))
164+ if presentURLs .count (contribRepo [1 ]) == 0 :
165+ settings .setValue (contribRepo [0 ]+ "/url" , QVariant (contribRepo [1 ]))
166+ settings .setValue (contribRepo [0 ]+ "/enabled" , QVariant (True ))
167+ else : # QGIS 0.x
168+ if presentURLs .count (oldRepo [1 ]) == 0 :
169+ settings .setValue (oldRepo [0 ]+ "/url" , QVariant (oldRepo [1 ]))
170+ settings .setValue (oldRepo [0 ]+ "/enabled" , QVariant (True ))
171+ # add author repositories
172+ for i in authorRepos :
173+ if i [1 ] and presentURLs .count (i [1 ]) == 0 :
159174 repoName = QString (i [0 ])
160175 if self .all ().has_key (repoName ):
161- repoName = repoName + "(2)"
162- # add to settings
163- settings .setValue (repoName + "/url" , QVariant (i [QGIS_MAJOR_VER + 1 ]))
176+ repoName = repoName + " (original)"
177+ settings .setValue (repoName + "/url" , QVariant (i [1 ]))
164178 settings .setValue (repoName + "/enabled" , QVariant (True ))
165179
166180
@@ -225,24 +239,32 @@ def load(self):
225239 self .mRepositories = {}
226240 settings = QSettings ()
227241 settings .beginGroup (reposGroup )
228- # first, update the QSettings repositories if needed
229- if len (settings .childGroups ()) == 0 : # add the default repository when there isn't any
230- settings .setValue (knownRepos [0 ][0 ]+ "/url" , QVariant (knownRepos [0 ][QGIS_MAJOR_VER + 1 ]))
231- else : # else update invalid urls
232- for key in settings .childGroups ():
233- url = settings .value (key + "/url" , QVariant ()).toString ()
234- allOk = True
235- for repo in knownRepos :
236- if repo [3 ] == url or repo [4 ] == url or (repo [QGIS_MAJOR_VER + 1 ] != url and repo [int (not QGIS_MAJOR_VER )+ 1 ] == url ):
237- if repo [QGIS_MAJOR_VER + 1 ]: #update the URL
238- settings .setValue (key + "/url" , QVariant (repo [QGIS_MAJOR_VER + 1 ]))
239- settings .setValue (key + "/valid" , QVariant (True ))
240- allOk = False
241- else : # mark as invalid
242- settings .setValue (key + "/valid" , QVariant (False ))
243- allOk = False
244- if allOk : # marking as valid if no problem.
245- settings .setValue (key + "/valid" , QVariant (True ))
242+ # first, update repositories in QSettings if needed
243+ if QGIS_MAJOR_VER :
244+ mainRepo = officialRepo
245+ invalidRepo = oldRepo
246+ else :
247+ mainRepo = oldRepo
248+ invalidRepo = officialRepo
249+ mainRepoPresent = False
250+ for key in settings .childGroups ():
251+ url = settings .value (key + "/url" , QVariant ()).toString ()
252+ if url == contribRepo [1 ]:
253+ if QGIS_MAJOR_VER :
254+ settings .setValue (key + "/valid" , QVariant (True )) # unlock the contrib repo in qgis 1.x
255+ else :
256+ settings .setValue (key + "/valid" , QVariant (False )) # lock the contrib repo in qgis 0.x
257+ else :
258+ settings .setValue (key + "/valid" , QVariant (True )) # unlock any other repo
259+ if url == mainRepo [1 ]:
260+ mainRepoPresent = True
261+ if url == invalidRepo [1 ]:
262+ settings .remove (key )
263+ for authorRepo in authorRepos :
264+ if url == authorRepo [2 ]:
265+ settings .setValue (key + "/url" , QVariant (authorRepo [1 ])) # correct a depreciated url
266+ if not mainRepoPresent :
267+ settings .setValue (mainRepo [0 ]+ "/url" , QVariant (mainRepo [1 ]))
246268
247269 for key in settings .childGroups ():
248270 self .mRepositories [key ] = {}
0 commit comments