当前位置: 首页>>代码示例>>C++>>正文


C++ Plugin::LoadMetadata方法代码示例

本文整理汇总了C++中Plugin::LoadMetadata方法的典型用法代码示例。如果您正苦于以下问题:C++ Plugin::LoadMetadata方法的具体用法?C++ Plugin::LoadMetadata怎么用?C++ Plugin::LoadMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin的用法示例。


在下文中一共展示了Plugin::LoadMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InstallPluginPackage

bool PluginManager::InstallPluginPackage(const wxString& filePath) {
  wxFileSystem fs;
  std::auto_ptr<wxZipEntry> entry(new wxZipEntry());

  wxFileInputStream in(filePath);
  if (!in.IsOk()) {
    MessageBoxes::ShowError(wxString::Format(_("Could not open %s"), filePath));
    return false;
  }

  wxString targetDir = FilePaths::GetPluginsDirectory();

  wxZipInputStream zip(in);
  
  while (entry.reset(zip.GetNextEntry()), entry.get() != NULL) {
    wxString name = entry->GetName();
    name = targetDir + wxFileName::GetPathSeparator() + name;

    if (entry->IsDir()) {
      int perm = entry->GetMode();
      wxFileName::Mkdir(name, perm, wxPATH_MKDIR_FULL);
    } else {
      zip.OpenEntry(*entry.get());

      if (!zip.CanRead()) {
        MessageBoxes::ShowError(wxString::Format(_("Can not read zip entry '%s'"), name));
        return false;
      }

      wxFileOutputStream file(name);

      if (!file) {
        MessageBoxes::ShowError(wxString::Format(_("Can not create file '%s'"), name));
        return false;
      }

      zip.Read(file);
    }

  }

  Plugin* p  = new Plugin();
  plugins_.push_back(p);
  p->LoadMetadata(targetDir);
  p->Enable(true);
  p->SetInitiallyEnabled(false);

  MessageBoxes::ShowInformation(wxString::Format(_("The plugin has been installed successfully. It will be activated the next time %s is started"), APPLICATION_NAME));

  return true;
}
开发者ID:DocWhoChat,项目名称:appetizer,代码行数:51,代码来源:PluginManager.cpp

示例2: Initialize

void PluginManager::Initialize() {
  eventNames_.Add(_T("iconMenuOpening"));
  eventNames_.Add(_T("click"));


  luaApplication = new azApplication();
  luaOptionPanel = new azOptionPanel();
  luaDialogs = new azDialogs();
  luaSystem = new azSystem();


  TiXmlDocument doc(FilePaths::GetPluginSettingsFile().mb_str());
  doc.LoadFile(TIXML_ENCODING_UTF8);
  TiXmlElement* pluginSettingsXml = doc.FirstChildElement("Plugins");
  if (!pluginSettingsXml) WLOG(_T("PluginManager::Initialize: Could not load XML. No Plugins element found."));


  wxString pluginPath = FilePaths::GetPluginsDirectory();
  wxDir pluginFolder;

  if (wxFileName::DirExists(pluginPath) && pluginFolder.Open(pluginPath)) {
    wxString folderName;
    bool success = pluginFolder.GetFirst(&folderName, wxALL_FILES_PATTERN, wxDIR_DIRS);
    
    while (success) {
      Plugin* p  = new Plugin();
      plugins_.push_back(p);

      wxString folderPath = pluginPath + wxFileName::GetPathSeparator() + folderName;

      p->LoadMetadata(folderPath);




      bool pluginIsEnabled = true;

      if (pluginSettingsXml) {        
        for (TiXmlElement* element = pluginSettingsXml->FirstChildElement(); element; element = element->NextSiblingElement()) {
          wxString elementName = wxString::FromUTF8(element->Value());
          TiXmlHandle handle(element);

          if (elementName == _T("Plugin")) {
            wxString uuid = XmlUtil::ReadElementText(handle, "UUID");
            if (uuid == p->GetUUID()) {
              pluginIsEnabled = XmlUtil::ReadElementTextAsBool(handle, "Enabled", true);
              break;          
            }
          } else {
            WLOG(wxString::Format(_T("PluginManager::Initialize: Unknown element: %s"), elementName));
          }
        } // for
      } // if




      p->Enable(pluginIsEnabled);
      p->SetInitiallyEnabled(pluginIsEnabled);

      if (pluginIsEnabled) {
        ILOG(_T("Loading plugin: ") + folderName);
        p->Load(folderPath);
      } else {
        ILOG(_T("Skipping disabled plugin: ") + folderName);
      }

      success = pluginFolder.GetNext(&folderName);
    }
  }
}
开发者ID:DocWhoChat,项目名称:appetizer,代码行数:71,代码来源:PluginManager.cpp


注:本文中的Plugin::LoadMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。