void FileDescriptionDBManager::loadDescriptions(const boost::filesystem::path& path)
{
	IR_ASSERT(boost::filesystem::is_directory(path), "FileDescriptionDBManager expects to receive path to a directory");
	
	for(auto i = boost::filesystem::directory_iterator(path); i != boost::filesystem::directory_iterator(); i++)
		if(boost::filesystem::is_regular_file(*i))
			loadDescription(i->path());
}
Exemplo n.º 2
0
bool MyMoneyTemplate::loadTemplate(const KUrl& url)
{
  QString filename;

  if (!url.isValid()) {
    qDebug("Invalid template URL '%s'", qPrintable(url.url()));
    return false;
  }

  m_source = url;
  if (url.isLocalFile()) {
    filename = url.toLocalFile();

  } else {
    bool rc;
    rc = KIO::NetAccess::download(url, filename, KMyMoneyUtils::mainWindow());
    if (!rc) {
      KMessageBox::detailedError(KMyMoneyUtils::mainWindow(),
                                 i18n("Error while loading file '%1'.", url.url()),
                                 KIO::NetAccess::lastErrorString(),
                                 i18n("File access error"));
      return false;
    }
  }

  bool rc = true;
  QFile file(filename);
  QFileInfo info(file);
  if (!info.isFile()) {
    QString msg = i18n("<p><b>%1</b> is not a template file.</p>", filename);
    KMessageBox::error(KMyMoneyUtils::mainWindow(), msg, i18n("Filetype Error"));
    return false;
  }

  if (file.open(QIODevice::ReadOnly)) {
    QString errMsg;
    int errLine, errColumn;
    if (!m_doc.setContent(&file, &errMsg, &errLine, &errColumn)) {
      QString msg = i18n("<p>Error while reading template file <b>%1</b> in line %2, column %3</p>", filename, errLine, errColumn);
      KMessageBox::detailedError(KMyMoneyUtils::mainWindow(), msg, errMsg, i18n("Template Error"));
      rc = false;
    } else {
      rc = loadDescription();
    }
    file.close();
  } else {
    KMessageBox::sorry(KMyMoneyUtils::mainWindow(), i18n("File '%1' not found.", filename));
    rc = false;
  }

  // if a temporary file was constructed by NetAccess::download,
  // then it will be removed with the next call. Otherwise, it
  // stays untouched on the local filesystem
  KIO::NetAccess::removeTempFile(filename);
  return rc;
}
Exemplo n.º 3
0
                        TVMediaServer::TVMediaServer(){
                            restoreUUID( string(Utils::getHomeDir()).append("/").append(UUID_PATH).c_str() );
                            bool ret = loadDescription(DESCRIPTION);
                            setDescriptionURI("/description.xml");
                            if (ret == false)
                                throw "Invalid description!";

                            conMan = new TVMSConnectionManager(this);
                            conDir = new TVMSContentDirectory(this);
                            regServ = new UPnPRegistrarService(this);
                        }
Exemplo n.º 4
0
Application::Application(const std::string path_name) :
    m_path(path_name) {

    // Check if path exists
    boost::filesystem::path pathfd(path());
    if (!boost::filesystem::exists(pathfd))
        throw AppNotFound();

    m_name = pathfd.filename();

    // The following paths are special cases and must not be used for applications
    if (name() == ".svn")
        throw InvalidPath();

    refreshVersions();
    loadDescription();
}
Exemplo n.º 5
0
                        TVDeviceId::TVDeviceId() : UPnPDevice() {
                            restoreUUID(string(Utils::getHomeDir()).append("/").append(".tvdeviceid.uuid").c_str());

                            if (loadDescription(TVDeviceId_DEVICE_DESCRIPTION) == false)
                                throw "Invalid description!";

                            if (getService()->loadSCPD(TVDeviceId_SERVICE_DESCRIPTION) == false)
                                throw "Invalid description!";

                            setUPnPActionListener(this);
                            setUPnPQueryListener(this);

                            upnpControl = UPnPDeviceController::getInstance();
                            upnpControl->addUPnPDeviceListener(this);
                            upnpControl->addUPnPEventListener(this);
                            btControl = BtDeviceController::getInstance();
                            btControl->addBtDeviceListener(this);

                            upnpControl->start();
                            btControl->start();
                        }
Exemplo n.º 6
0
void MetadataItem::ensureDescriptionLoaded()
{
    if (descriptionLoadedM == lsNotLoaded)
        loadDescription();
}