Logo Search packages:      
Sourcecode: packagesearch version File versions

void NPlugin::DebtagsPluginContainer::updateDebtags (  )  [protected]

Loads the latest debtags database and informs the plugins about the changing of the database.

Behaves sound when loading fails (informing plugins about set to zero).

Todo:
add error handling here, but currently it is not supported because of bad exception specification in the Environment class

Definition at line 229 of file debtagsplugincontainer.cpp.

References _facets, _pCollection, _pDebtagsPlugin, _pRelatedPlugin, NPlugin::DebtagsPlugin::debtagsDataChanged(), debtagsEnabled(), NPlugin::IProvider::progressObserver(), NPlugin::BasePluginContainer::provider(), NPlugin::IProvider::reportError(), setDebtagsEnabled(), NUtil::IProgressObserver::setProgress(), NUtil::IProgressObserver::setText(), and updateVocabulary().

Referenced by onDebtagsUpdateFinished().

{
      if ( !Debtags::TagDB::hasTagDatabase() )  // not all debtags files are existent
      {
            provider()->reportError(
                  tr("Tag Database Not Available" ),
                  tr(
                        "<p>The tag database is not available and the  debtags plugin was disabled!</p>"
                        "<p>"
                        "You must execute <tt><b>debtags update</b></tt> as root on the commandline to download "
                        "the database. If debtags is not on your system you can install it via "
                        "<tt><b>apt-get install debtags</b></tt><br>"
                        "After this you can enable the debtags plugin via the plugin menu -> Control Plugins."
                        "</p>"
                  ) 
            );
            /* New text
                                    tr(
                                    "<p>The tag database is not available!</p>"
                                    "The database is required "
                                    "by this program. Do you want to try downloading it now?<br>"
                                    "Note: Super user priviledges are needed for this. You can also update by hand "
                                    "executing <tt>debtags update</tt> on the commandline.<br>"
                                    "If debtags is not on your system you can get it via <tt>apt-get install debtags</tt>."
                                    "</p>"
                              ),
                              QMessageBox::Yes, QMessageBox::No )
                        == 0
            */
            setDebtagsEnabled(false);     // disable the debtags system
      }
      else 
            setDebtagsEnabled(true);
      delete _pCollection;
      _pCollection = 0;
      _facets.clear();
      if (debtagsEnabled())
      {
            try
            {
                  // this is set to 0 if no listener is available
                  NUtil::IProgressObserver* pProgressObserver = provider()->progressObserver();
                  if (pProgressObserver)
                  {
                        pProgressObserver->setText("reading tag database");
                  }
                  Tagcoll::InputMerger<int, string> merger;
                  Tagcoll::TagcollBuilder collBuilder(*_pHandleMaker);
                  // load the database into the collBuilder and change it to handles
                  Debtags::TagDB::outputSystem(collBuilder, false);
                  if (pProgressObserver)
                  {
                        pProgressObserver->setProgress(25);
                  }
                  // now sent the collection to the InputMerger
                  collBuilder.collection().output(merger);
                  if (pProgressObserver)
                  {
                        pProgressObserver->setProgress(50);
                  }
                  // output the merger to create a collection
                  _pCollection = new Tagcoll::TagCollection<int, string>();
                  merger.output(*_pCollection);
                  if (pProgressObserver)
                  {
                        pProgressObserver->setProgress(75);
                        pProgressObserver->setText("reading vocabulary");
                  }
                  ///@todo add error handling here, but currently it is not supported because of bad
                  /// exception specification in the Environment class
                  // load the new vocabulary
                  updateVocabulary(false);
                  if (pProgressObserver)
                  {
                        pProgressObserver->setProgress(100);
                  }
            }     
            catch (ContextException& e)   // PackageDBException e
                  // this might be a FileException, a ParserException or a PackageDBException
            {
                  provider()->reportError(
                        tr("Loading failed"),
                        QObject::tr(
                        "<p>Loading the debtags database failed!</p>"
                        "<p>Most likely it is malformed.<br>"
                        "Try selecting \"System\"->\"Debtags Update\" from the menu or running "
                        "<tt>debtags update</tt> on the commandline."
                        "</p>"
                        "This was the original error message:<br>") 
                        + toQString(e.desc())
                  );
            }
      }
      // inform the plugins about the new collections
      if (_pDebtagsPlugin)
            _pDebtagsPlugin->debtagsDataChanged();
      if (_pRelatedPlugin)
            _pRelatedPlugin->debtagsDataChanged();
}


Generated by  Doxygen 1.6.0   Back to index