Ejemplo n.º 1
0
bool XAP_Dialog_PluginManager::activatePlugin (const char * szURI) const
{
	UT_return_val_if_fail (szURI, false);

	char * szName = UT_go_filename_from_uri(szURI);
	if(szName) {
	  bool loaded = XAP_ModuleManager::instance ().loadModule (szName);
	  g_free(szName);
	  return loaded;
	}
	return false;
}
Ejemplo n.º 2
0
UT_Error IE_Exp_EPUB::compress()
{

    GsfInfile* oebpsDir = gsf_infile_stdio_new(
            UT_go_filename_from_uri(m_oebpsDir.c_str()), NULL);

    if (oebpsDir == NULL)
    {
        UT_DEBUGMSG(("RUDYJ: Can`t open temporary OEBPS directory\n"));
        return UT_ERROR;
    }

    std::vector<std::string> listing = getFileList(
            UT_go_filename_from_uri(m_oebpsDir.c_str()));
    for (std::vector<std::string>::iterator i = listing.begin(); i
            != listing.end(); i++)
    {
        GsfOutput* item = gsf_outfile_new_child(GSF_OUTFILE(m_oebps),
                (*i).c_str(), FALSE);
	std::string fullPath = m_oebpsDir + G_DIR_SEPARATOR_S + *i;
        GsfInput* file = UT_go_file_open(fullPath.c_str(), NULL);

        if (file == NULL)
        {
            UT_DEBUGMSG(("RUDYJ: Can`t open file\n"));
            return UT_ERROR;
        }

        gsf_output_seek(item, 0, G_SEEK_SET);
        gsf_input_seek(file, 0, G_SEEK_SET);
        gsf_input_copy(file, item);
        gsf_output_close(item);
        // Time to delete temporary file
        UT_go_file_remove(fullPath.c_str(), NULL);
    }

    UT_go_file_remove((m_oebpsDir + G_DIR_SEPARATOR_S + "index.xhtml_files").c_str(), NULL);
    UT_go_file_remove(m_oebpsDir.c_str(), NULL);
	return UT_OK;
}
Ejemplo n.º 3
0
UT_Error IE_Imp_EPUB::uncompress()
{
    m_tmpDir = UT_go_filename_to_uri(g_get_tmp_dir());
    m_tmpDir += G_DIR_SEPARATOR_S;
    m_tmpDir += getDoc()->getDocUUIDString();

    if (!UT_go_directory_create(m_tmpDir.c_str(), 0644, NULL))
    {
        UT_DEBUGMSG(("Can`t create temporary directory\n"));
        return UT_ERROR;
    }
    GsfInput *opsDirInput = gsf_infile_child_by_name(m_epub,
            m_opsDir.c_str());
    UT_DEBUGMSG(("Child count : %d", gsf_infile_num_children(m_epub)));
    if (opsDirInput == NULL)
    {
        UT_DEBUGMSG(("Failed to open OPS dir\n"));
        return UT_ERROR;
    }

    for (std::map<std::string, std::string>::iterator i =
            m_manifestItems.begin(); i != m_manifestItems.end(); i++)
    {
        gchar *itemFileName = UT_go_filename_from_uri(
                (m_tmpDir + G_DIR_SEPARATOR_S + (*i).second).c_str());
        gchar** aname =
                g_strsplit((*i).second.c_str(), G_DIR_SEPARATOR_S, 0);

        GsfInput* itemInput = gsf_infile_child_by_aname(
                GSF_INFILE(opsDirInput), (const char**) aname);
        GsfOutput* itemOutput = createFileByPath(itemFileName);
        gsf_input_seek(itemInput, 0, G_SEEK_SET);
        gsf_input_copy(itemInput, itemOutput);
        g_strfreev(aname);
        g_free(itemFileName);
        g_object_unref(G_OBJECT(itemInput));
        gsf_output_close(itemOutput);
    }

    g_object_unref(G_OBJECT(opsDirInput));

    return UT_OK;
}
Ejemplo n.º 4
0
GsfOutput* IE_Exp_OpenDocument::_openFile(const char *szFilename)
{
  GsfOutput *output = NULL;

  const std::string & prop = getProperty ("uncompressed");

  if (!prop.empty() && UT_parseBool (prop.c_str (), false))
    {
      char *filename = UT_go_filename_from_uri (szFilename);
      if (filename) 
	{
	  output = (GsfOutput*)gsf_outfile_stdio_new (filename, NULL);
	  g_free (filename);
	}
    }
  else
    {
      output = IE_Exp::_openFile (szFilename);
    }

  return output;
}