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


C++ CStdString::empty方法代码示例

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


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

示例1: getTemperature

bool CCPUInfo::getTemperature(CTemperature& temperature)
{
  int         value = 0;
  char        scale = 0;
  
#ifdef TARGET_POSIX
#if defined(TARGET_DARWIN_OSX)
  value = SMCGetTemperature(SMC_KEY_CPU_TEMP);
  scale = 'c';
#else
  int         ret   = 0;
  FILE        *p    = NULL;
  CStdString  cmd   = g_advancedSettings.m_cpuTempCmd;

  temperature.SetState(CTemperature::invalid);

  if (cmd.empty() && m_fProcTemperature == NULL)
    return false;

  if (!cmd.empty())
  {
    p = popen (cmd.c_str(), "r");
    if (p)
    {
      ret = fscanf(p, "%d %c", &value, &scale);
      pclose(p);
    }
  }
  else
  {
    // procfs is deprecated in the linux kernel, we should move away from
    // using it for temperature data.  It doesn't seem that sysfs has a
    // general enough interface to bother implementing ATM.
    
    rewind(m_fProcTemperature);
    fflush(m_fProcTemperature);
    ret = fscanf(m_fProcTemperature, "temperature: %d %c", &value, &scale);
    
    // read from the temperature file of the new kernels
    if (!ret)
    {
      ret = fscanf(m_fProcTemperature, "%d", &value);
      value = value / 1000;
      scale = 'c';
      ret++;
    }
  }

  if (ret != 2)
    return false; 
#endif
#endif // TARGET_POSIX

  if (scale == 'C' || scale == 'c')
    temperature = CTemperature::CreateFromCelsius(value);
  else if (scale == 'F' || scale == 'f')
    temperature = CTemperature::CreateFromFahrenheit(value);
  else
    return false;
  
  return true;
}
开发者ID:mghome59,项目名称:xbmc,代码行数:62,代码来源:CPUInfo.cpp

示例2: Process

void CRssReader::Process()
{
  while (GetQueueSize())
  {
    CSingleLock lock(m_critical);

    int iFeed = m_vecQueue.front();
    m_vecQueue.erase(m_vecQueue.begin());

    m_strFeed[iFeed] = "";
    m_strColors[iFeed] = "";

    CCurlFile http;
    http.SetUserAgent(g_advancedSettings.m_userAgent);
    http.SetTimeout(2);
    CStdString strXML;
    CStdString strUrl = m_vecUrls[iFeed];
    lock.Leave();

    int nRetries = 3;
    CURL url(strUrl);
    std::string fileCharset;

    // we wait for the network to come up
    if ((url.GetProtocol() == "http" || url.GetProtocol() == "https") &&
        !g_application.getNetwork().IsAvailable(true))
    {
      CLog::Log(LOGWARNING, "RSS: No network connection");
      strXML = "<rss><item><title>"+g_localizeStrings.Get(15301)+"</title></item></rss>";
    }
    else
    {
      XbmcThreads::EndTime timeout(15000);
      while (!m_bStop && nRetries > 0)
      {
        if (timeout.IsTimePast())
        {
          CLog::Log(LOGERROR, "Timeout whilst retrieving %s", strUrl.c_str());
          http.Cancel();
          break;
        }
        nRetries--;

        if (url.GetProtocol() != "http" && url.GetProtocol() != "https")
        {
          CFile file;
          auto_buffer buffer;
          if (file.LoadFile(strUrl, buffer))
          {
            strXML.assign(buffer.get(), buffer.length());
            break;
          }
        }
        else
          if (http.Get(strUrl, strXML))
          {
            fileCharset = http.GetServerReportedCharset();
            CLog::Log(LOGDEBUG, "Got rss feed: %s", strUrl.c_str());
            break;
          }
      }
      http.Cancel();
    }
    if (!strXML.empty() && m_pObserver)
    {
      // erase any <content:encoded> tags (also unsupported by tinyxml)
      size_t iStart = strXML.find("<content:encoded>");
      size_t iEnd = 0;
      while (iStart != std::string::npos)
      {
        // get <content:encoded> end position
        iEnd = strXML.find("</content:encoded>", iStart) + 18;

        // erase the section
        strXML = strXML.erase(iStart, iEnd - iStart);

        iStart = strXML.find("<content:encoded>");
      }

      if (Parse(strXML, iFeed, fileCharset))
        CLog::Log(LOGDEBUG, "Parsed rss feed: %s", strUrl.c_str());
    }
  }
  UpdateObserver();
}
开发者ID:B0k0,项目名称:xbmc,代码行数:85,代码来源:RssReader.cpp

示例3: SetOption


//.........这里部分代码省略.........
			str.Replace('\n', ' ');
			str.Replace('\r', ' ');
			while (str.Replace(_T("  "), _T(" ")));
			str += _T(" ");

			CStdString ips;

			int pos = str.Find(' ');
			while (pos != -1)
			{
				CStdString sub = str.Left(pos);
				str = str.Mid(pos + 1);
				str.TrimLeft(' ');

				if (sub == _T("*"))
					ips += _T(" ") + sub;
				else
				{
					if (IsValidAddressFilter(sub))
						ips += " " + sub;
					pos = str.Find(' ');
				}
			}
			ips.TrimLeft(' ');

			str = ips;
		}
		break;
	case OPTION_IPBINDINGS:
		{
			std::list<CStdString> ipBindList;

			str += _T(" ");
			while (!str.empty()) {
				int pos  = str.Find(' ');
				if (pos < 0) {
					break;
				}
				CStdString sub = str.Left(pos);
				str = str.Mid(pos + 1);

				if (sub == _T("*")) {
					ipBindList.clear();
					ipBindList.push_back(_T("*"));
					break;
				}
				else if (IsIpAddress(sub, true)) {
					ipBindList.push_back(sub);
				}
			}

			if (ipBindList.empty())
				ipBindList.push_back(_T("*"));

			str.clear();
			for (auto const& ip : ipBindList) {
				str += ip + _T(" ");
			}

			str.TrimRight(_T(" "));
		}
		break;
	case OPTION_CUSTOMPASVIPSERVER:
		if (str.Find(_T("filezilla.sourceforge.net")) != -1)
			str = _T("http://ip.filezilla-project.org/ip.php");
		break;
开发者ID:alioxp,项目名称:vc,代码行数:67,代码来源:Options.cpp

示例4: DownloadArtistInfo


//.........这里部分代码省略.........
    {
      if (m_bStop)
      {
        scraper.Cancel();
        bCanceled = true;
      }
      Sleep(1);
    }
  }

  int iSelectedArtist = 0;
  if (result == CNfoFile::NO_NFO)
  {
    if (scraper.Succeeded() && scraper.GetArtistCount() >= 1)
    {
      // now load the first match
      if (pDialog && scraper.GetArtistCount() > 1)
      {
        // if we found more then 1 album, let user choose one
        CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
        if (pDlg)
        {
          pDlg->SetHeading(g_localizeStrings.Get(21890));
          pDlg->Reset();
          pDlg->EnableButton(true, 413); // manual

          for (int i = 0; i < scraper.GetArtistCount(); ++i)
          {
            // set the label to artist
            CFileItem item(scraper.GetArtist(i).GetArtist());
            CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist;
            if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty())
              strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")";
            if (!scraper.GetArtist(i).GetArtist().genre.empty())
            {
              CStdString genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator);
              if (!genres.empty())
                strTemp.Format("[%s] %s", genres.c_str(), strTemp.c_str());
            }
            item.SetLabel(strTemp);
            item.m_idepth = i; // use this to hold the index of the album in the scraper
            pDlg->Add(&item);
          }
          pDlg->DoModal();

          // and wait till user selects one
          if (pDlg->GetSelectedLabel() < 0)
          { // none chosen
            if (!pDlg->IsButtonPressed())
            {
              bCanceled = true;
              return false;
            }
            // manual button pressed
            CStdString strNewArtist = strArtist;
            if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;

            if (pDialog)
            {
              pDialog->SetLine(0, strNewArtist);
              pDialog->Progress();
            }
            m_musicDatabase.Close();
            return DownloadArtistInfo(strPath,strNewArtist,bCanceled,pDialog);
          }
          iSelectedArtist = pDlg->GetSelectedItem()->m_idepth;
开发者ID:A600,项目名称:xbmc,代码行数:67,代码来源:MusicInfoScanner.cpp

示例5: OnPathBrowse

void CGUIDialogMediaSource::OnPathBrowse(int item)
{
  if (item < 0 || item > m_paths->Size()) return;
  // Browse is called.  Open the filebrowser dialog.
  // Ignore current path is best at this stage??
  CStdString path;
  bool allowNetworkShares(m_type != "programs");
  VECSOURCES extraShares;

  if (m_name != CUtil::GetTitleFromPath(m_paths->Get(item)->GetPath()))
    m_bNameChanged=true;

  if (m_type == "music")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "music") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20240);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the music playlist location
    share1.strPath = "special://musicplaylists/";
    share1.strName = g_localizeStrings.Get(20011);
    share1.m_ignore = true;
    extraShares.push_back(share1);

    share1.strPath = "sap://";
    share1.strName = "SAP Streams";
    extraShares.push_back(share1);

    if (g_guiSettings.GetString("audiocds.recordingpath",false) != "")
    {
      share1.strPath = "special://recordings/";
      share1.strName = g_localizeStrings.Get(21883);
      extraShares.push_back(share1);
    }

 }
  else if (m_type == "video")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android video directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "videos") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20241);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the video playlist location
    share1.m_ignore = true;
    share1.strPath = "special://videoplaylists/";
    share1.strName = g_localizeStrings.Get(20012);
    extraShares.push_back(share1);

    share1.strPath = "rtv://*/";
    share1.strName = "ReplayTV Devices";
    extraShares.push_back(share1);

    share1.strPath = "hdhomerun://";
    share1.strName = "HDHomerun Devices";
    extraShares.push_back(share1);

    share1.strPath = "sap://";
    share1.strName = "SAP Streams";
    extraShares.push_back(share1);

    // add the recordings dir as needed
    if (CPVRDirectory::HasRecordings())
    {
      share1.strPath = "pvr://recordings/";
      share1.strName = g_localizeStrings.Get(19017); // TV Recordings
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "pictures")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "pictures") && !path.empty() &&  CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20242);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }

//.........这里部分代码省略.........
开发者ID:2BReality,项目名称:xbmc,代码行数:101,代码来源:GUIDialogMediaSource.cpp

示例6: Process

void CPeripheralCecAdapter::Process(void)
{
  if (!GetSettingBool("enabled"))
  {
    CLog::Log(LOGDEBUG, "%s - CEC adapter is disabled in peripheral settings", __FUNCTION__);
    m_bStarted = false;
    return;
  }
  
  CStdString strPort = GetComPort();
  if (strPort.empty())
    return;

  // set correct physical address from peripheral settings
  int iHdmiPort = GetSettingInt("cec_hdmi_port");
  SetHdmiPort(iHdmiPort);
  FlushLog();

  // open the CEC adapter
  CLog::Log(LOGDEBUG, "%s - opening a connection to the CEC adapter: %s", __FUNCTION__, strPort.c_str());

  // scanning the CEC bus takes about 5 seconds, so display a notification to inform users that we're busy
  CStdString strMessage;
  strMessage.Format(g_localizeStrings.Get(21336), g_localizeStrings.Get(36000));
  CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), strMessage);

  if (!m_cecAdapter->Open(strPort.c_str(), 10000))
  {
    FlushLog();
    CLog::Log(LOGERROR, "%s - could not opening a connection to the CEC adapter", __FUNCTION__);
    CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), g_localizeStrings.Get(36012));
    m_bStarted = false;
    return;
  }

  CLog::Log(LOGDEBUG, "%s - connection to the CEC adapter opened", __FUNCTION__);
  m_bIsReady = true;
  CAnnouncementManager::AddAnnouncer(this);

  if (GetSettingBool("cec_power_on_startup"))
  {
    PowerOnCecDevices(CECDEVICE_TV);
    FlushLog();
  }

  if (GetSettingBool("use_tv_menu_language"))
  {
    cec_menu_language language;
    if (m_cecAdapter->GetDeviceMenuLanguage(CECDEVICE_TV, &language))
      SetMenuLanguage(language.language);
  }

  m_cecAdapter->SetOSDString(CECDEVICE_TV, CEC_DISPLAY_CONTROL_DISPLAY_FOR_DEFAULT_TIME, g_localizeStrings.Get(36016).c_str());
  CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), g_localizeStrings.Get(36016));

  while (!m_bStop)
  {
    FlushLog();
    if (!m_bStop)
      ProcessNextCommand();
    if (!m_bStop)
      Sleep(5);
  }

  m_cecAdapter->Close();

  CLog::Log(LOGDEBUG, "%s - CEC adapter processor thread ended", __FUNCTION__);
  m_bStarted = false;
}
开发者ID:Gemini88,项目名称:xbmc-1,代码行数:69,代码来源:PeripheralCecAdapter.cpp

示例7: TakeScreenshot

void CScreenShot::TakeScreenshot()
{
  static bool savingScreenshots = false;
  static vector<CStdString> screenShots;
  bool promptUser = false;
  CStdString strDir;

  // check to see if we have a screenshot folder yet
  CSettingPath *screenshotSetting = (CSettingPath*)CSettings::Get().GetSetting("debug.screenshotpath");
  if (screenshotSetting != NULL)
  {
    strDir = screenshotSetting->GetValue();
    if (strDir.empty())
    {
      if (CGUIControlButtonSetting::GetPath(screenshotSetting))
        strDir = screenshotSetting->GetValue();
    }
  }

  if (strDir.IsEmpty())
  {
    strDir = "special://temp/";
    if (!savingScreenshots)
    {
      promptUser = true;
      savingScreenshots = true;
      screenShots.clear();
    }
  }
  URIUtils::RemoveSlashAtEnd(strDir);

  if (!strDir.IsEmpty())
  {
    CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(strDir, "screenshot%03d.png"), 999);

    if (!file.IsEmpty())
    {
      TakeScreenshot(file, false);
      if (savingScreenshots)
        screenShots.push_back(file);
      if (promptUser)
      { // grab the real directory
        CStdString newDir;
        if (screenshotSetting != NULL)
        {
          newDir = screenshotSetting->GetValue();
          if (newDir.empty())
          {
            if (CGUIControlButtonSetting::GetPath(screenshotSetting))
              newDir = screenshotSetting->GetValue();
          }
        }

        if (!newDir.IsEmpty())
        {
          for (unsigned int i = 0; i < screenShots.size(); i++)
          {
            CStdString file = CUtil::GetNextFilename(URIUtils::AddFileToFolder(newDir, "screenshot%03d.png"), 999);
            CFile::Cache(screenShots[i], file);
          }
          screenShots.clear();
        }
        savingScreenshots = false;
      }
    }
    else
    {
      CLog::Log(LOGWARNING, "Too many screen shots or invalid folder");
    }
  }
}
开发者ID:Micromax-56,项目名称:xbmc,代码行数:71,代码来源:Screenshot.cpp

示例8: FillFileItemList

bool CFileOperations::FillFileItemList(const CVariant &parameterObject, CFileItemList &list)
{
  if (parameterObject.isMember("directory"))
  {
    CStdString media =  parameterObject["media"].asString();
    media = media.ToLower();

    CStdString strPath = parameterObject["directory"].asString();
    if (!strPath.empty())
    {
      CFileItemList items;
      CStdString extensions = "";
      CStdStringArray regexps;

      if (media.Equals("video"))
      {
        regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
        extensions = g_settings.m_videoExtensions;
      }
      else if (media.Equals("music"))
      {
        regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
        extensions = g_settings.m_musicExtensions;
      }
      else if (media.Equals("pictures"))
      {
        regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
        extensions = g_settings.m_pictureExtensions;
      }

      CDirectory directory;
      if (directory.GetDirectory(strPath, items, extensions))
      {
        items.Sort(SORT_METHOD_FILE, SortOrderAscending);
        CFileItemList filteredDirectories;
        for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
        {
          if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
            continue;

          if (items[i]->m_bIsFolder)
            filteredDirectories.Add(items[i]);
          else if ((media == "video" && items[i]->HasVideoInfoTag()) ||
                   (media == "music" && items[i]->HasMusicInfoTag()))
            list.Add(items[i]);
          else
          {
            CFileItem fileItem;
            if (FillFileItem(items[i], fileItem, media, parameterObject))
              list.Add(CFileItemPtr(new CFileItem(fileItem)));
            else if (media == "files")
              list.Add(items[i]);
          }
        }

        if (parameterObject.isMember("recursive") && parameterObject["recursive"].isBoolean())
        {
          for (int i = 0; i < filteredDirectories.Size(); i++)
          {
            CVariant val = parameterObject;
            val["directory"] = filteredDirectories[i]->GetPath();
            FillFileItemList(val, list);
          }
        }

        return true;
      }
    }
  }

  return false;
}
开发者ID:mikedoner,项目名称:xbmc,代码行数:72,代码来源:FileOperations.cpp

示例9: GetDirectory

bool CLibraryDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
  std::string libNode = GetNode(url);
  if (libNode.empty())
    return false;

  if (URIUtils::HasExtension(libNode, ".xml"))
  { // a filter or folder node
    TiXmlElement *node = LoadXML(libNode);
    if (node)
    {
      CStdString type = node->Attribute("type");
      if (type == "filter")
      {
        CSmartPlaylist playlist;
        CStdString type, label;
        XMLUtils::GetString(node, "content", type);
        if (type.empty())
        {
          CLog::Log(LOGERROR, "<content> tag must not be empty for type=\"filter\" node '%s'", libNode.c_str());
          return false;
        }
        if (XMLUtils::GetString(node, "label", label))
          label = CGUIControlFactory::FilterLabel(label);
        playlist.SetType(type);
        playlist.SetName(label);
        if (playlist.LoadFromXML(node) &&
            CSmartPlaylistDirectory::GetDirectory(playlist, items))
        {
          items.SetProperty("library.filter", "true");
          items.SetPath(items.GetProperty("path.db").asString());
          return true;
        }
      }
      else if (type == "folder")
      {
        CStdString path;
        XMLUtils::GetPath(node, "path", path);
        if (!path.empty())
        {
          URIUtils::AddSlashAtEnd(path);
          return CDirectory::GetDirectory(path, items, m_strFileMask, m_flags);
        }
      }
    }
    return false;
  }

  // just a plain node - read the folder for XML nodes and other folders
  CFileItemList nodes;
  if (!CDirectory::GetDirectory(libNode, nodes, ".xml", DIR_FLAG_NO_FILE_DIRS))
    return false;

  // iterate over our nodes
  std::string basePath = url.Get();
  for (int i = 0; i < nodes.Size(); i++)
  {
    const TiXmlElement *node = NULL;
    CStdString xml = nodes[i]->GetPath();
    if (nodes[i]->m_bIsFolder)
      node = LoadXML(URIUtils::AddFileToFolder(xml, "index.xml"));
    else
    {
      node = LoadXML(xml);
      if (node && URIUtils::GetFileName(xml).Equals("index.xml"))
      { // set the label on our items
        CStdString label;
        if (XMLUtils::GetString(node, "label", label))
          label = CGUIControlFactory::FilterLabel(label);
        items.SetLabel(label);
        continue;
      }
    }
    if (node)
    {
      CStdString label, icon;
      if (XMLUtils::GetString(node, "label", label))
        label = CGUIControlFactory::FilterLabel(label);
      XMLUtils::GetString(node, "icon", icon);
      int order = 0;
      node->Attribute("order", &order);

      // create item
      URIUtils::RemoveSlashAtEnd(xml);
      CStdString folder = URIUtils::GetFileName(xml);
      CFileItemPtr item(new CFileItem(URIUtils::AddFileToFolder(basePath, folder), true));

      item->SetLabel(label);
      if (!icon.empty() && g_TextureManager.HasTexture(icon))
        item->SetIconImage(icon);
      item->m_iprogramCount = order;
      items.Add(item);
    }
  }
  items.Sort(SortByPlaylistOrder, SortOrderAscending);
  return true;
}
开发者ID:B0k0,项目名称:xbmc,代码行数:97,代码来源:LibraryDirectory.cpp

示例10: GetField

std::string DatabaseUtils::GetField(Field field, MediaType mediaType, DatabaseQueryPart queryPart)
{
    if (field == FieldNone || mediaType == MediaTypeNone)
        return "";

    if (mediaType == MediaTypeAlbum)
    {
        if (field == FieldId) return "albumview.idAlbum";
        else if (field == FieldAlbum) return "albumview.strAlbum";
        else if (field == FieldArtist || field == FieldAlbumArtist) return "albumview.strArtists";
        else if (field == FieldGenre) return "albumview.strGenre";
        else if (field == FieldYear) return "albumview.iYear";
        else if (field == FieldMoods) return "albumview.strMoods";
        else if (field == FieldStyles) return "albumview.strStyles";
        else if (field == FieldThemes) return "albumview.strThemes";
        else if (field == FieldReview) return "albumview.strReview";
        else if (field == FieldMusicLabel) return "albumview.strLabel";
        else if (field == FieldAlbumType) return "albumview.strType";
        else if (field == FieldRating) return "albumview.iRating";
        else if (field == FieldDateAdded && queryPart == DatabaseQueryPartOrderBy) return "albumview.idalbum";    // only used for order clauses
        else if (field == FieldPlaycount) return "albumview.iTimesPlayed";
    }
    else if (mediaType == MediaTypeSong)
    {
        if (field == FieldId) return "songview.idSong";
        else if (field == FieldTitle) return "songview.strTitle";
        else if (field == FieldTrackNumber) return "songview.iTrack";
        else if (field == FieldTime) return "songview.iDuration";
        else if (field == FieldYear) return "songview.iYear";
        else if (field == FieldFilename) return "songview.strFilename";
        else if (field == FieldPlaycount) return "songview.iTimesPlayed";
        else if (field == FieldStartOffset) return "songview.iStartOffset";
        else if (field == FieldEndOffset) return "songview.iEndOffset";
        else if (field == FieldLastPlayed) return "songview.lastPlayed";
        else if (field == FieldRating) return "songview.rating";
        else if (field == FieldComment) return "songview.comment";
        else if (field == FieldAlbum) return "songview.strAlbum";
        else if (field == FieldPath) return "songview.strPath";
        else if (field == FieldArtist || field == FieldAlbumArtist) return "songview.strArtists";
        else if (field == FieldGenre) return "songview.strGenre";
        else if (field == FieldDateAdded && queryPart == DatabaseQueryPartOrderBy) return "songview.idSong";     // only used for order clauses
    }
    else if (mediaType == MediaTypeArtist)
    {
        if (field == FieldId) return "artistview.idArtist";
        else if (field == FieldArtist) return "artistview.strArtist";
        else if (field == FieldGenre) return "artistview.strGenres";
        else if (field == FieldMoods) return "artistview.strMoods";
        else if (field == FieldStyles) return "artistview.strStyles";
        else if (field == FieldInstruments) return "artistview.strInstruments";
        else if (field == FieldBiography) return "artistview.strBiography";
        else if (field == FieldBorn) return "artistview.strBorn";
        else if (field == FieldBandFormed) return "artistview.strFormed";
        else if (field == FieldDisbanded) return "artistview.strDisbanded";
        else if (field == FieldDied) return "artistview.strDied";
    }
    else if (mediaType == MediaTypeMusicVideo)
    {
        CStdString result;
        if (field == FieldId) return "musicvideoview.idMVideo";
        else if (field == FieldTitle) result.Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_TITLE);
        else if (field == FieldTime) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_RUNTIME);
        else if (field == FieldDirector) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_DIRECTOR);
        else if (field == FieldStudio) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_STUDIOS);
        else if (field == FieldYear) result.Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_YEAR);
        else if (field == FieldPlot) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_PLOT);
        else if (field == FieldAlbum) result.Format("musicvideoview.c%02d",VIDEODB_ID_MUSICVIDEO_ALBUM);
        else if (field == FieldArtist) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_ARTIST);
        else if (field == FieldGenre) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_GENRE);
        else if (field == FieldTrackNumber) result.Format("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_TRACK);
        else if (field == FieldFilename) return "musicvideoview.strFilename";
        else if (field == FieldPath) return "musicvideoview.strPath";
        else if (field == FieldPlaycount) return "musicvideoview.playCount";
        else if (field == FieldLastPlayed) return "musicvideoview.lastPlayed";
        else if (field == FieldDateAdded) return "musicvideoview.dateAdded";

        if (!result.empty())
            return result;
    }
    else if (mediaType == MediaTypeMovie)
    {
        CStdString result;
        if (field == FieldId) return "movieview.idMovie";
        else if (field == FieldTitle)
        {
            // We need some extra logic to get the title value if sorttitle isn't set
            if (queryPart == DatabaseQueryPartOrderBy)
                result.Format("CASE WHEN length(movieview.c%02d) > 0 THEN movieview.c%02d ELSE movieview.c%02d END", VIDEODB_ID_SORTTITLE, VIDEODB_ID_SORTTITLE, VIDEODB_ID_TITLE);
            else
                result.Format("movieview.c%02d", VIDEODB_ID_TITLE);
        }
        else if (field == FieldPlot) result.Format("movieview.c%02d", VIDEODB_ID_PLOT);
        else if (field == FieldPlotOutline) result.Format("movieview.c%02d", VIDEODB_ID_PLOTOUTLINE);
        else if (field == FieldTagline) result.Format("movieview.c%02d", VIDEODB_ID_TAGLINE);
        else if (field == FieldVotes) result.Format("movieview.c%02d", VIDEODB_ID_VOTES);
        else if (field == FieldRating)
        {
            if (queryPart == DatabaseQueryPartOrderBy)
                result.Format("CAST(movieview.c%02d as DECIMAL(5,3))", VIDEODB_ID_RATING);
            else
//.........这里部分代码省略.........
开发者ID:blacksocket,项目名称:xbmc,代码行数:101,代码来源:DatabaseUtils.cpp

示例11: GetSettingsFromMappingsFile

void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdString, PeripheralDeviceSetting> &settings)
{
  TiXmlElement *currentNode = xmlNode->FirstChildElement("setting");
  int iMaxOrder = 0;

  while (currentNode)
  {
    CSetting *setting = NULL;
    CStdString strKey = XMLUtils::GetAttribute(currentNode, "key");
    if (strKey.empty())
      continue;

    CStdString strSettingsType = XMLUtils::GetAttribute(currentNode, "type");
    int iLabelId = currentNode->Attribute("label") ? atoi(currentNode->Attribute("label")) : -1;
    const std::string config = XMLUtils::GetAttribute(currentNode, "configurable");
    bool bConfigurable = (config.empty() || (config != "no" && config != "false" && config != "0"));
    if (strSettingsType.Equals("bool"))
    {
      const std::string value = XMLUtils::GetAttribute(currentNode, "value");
      bool bValue = (value != "no" && value != "false" && value != "0");
      setting = new CSettingBool(strKey, iLabelId, bValue);
    }
    else if (strSettingsType.Equals("int"))
    {
      int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
      int iMin   = currentNode->Attribute("min") ? atoi(currentNode->Attribute("min")) : 0;
      int iStep  = currentNode->Attribute("step") ? atoi(currentNode->Attribute("step")) : 1;
      int iMax   = currentNode->Attribute("max") ? atoi(currentNode->Attribute("max")) : 255;
      setting = new CSettingInt(strKey, iLabelId, iValue, iMin, iStep, iMax);
    }
    else if (strSettingsType.Equals("float"))
    {
      float fValue = currentNode->Attribute("value") ? (float) atof(currentNode->Attribute("value")) : 0;
      float fMin   = currentNode->Attribute("min") ? (float) atof(currentNode->Attribute("min")) : 0;
      float fStep  = currentNode->Attribute("step") ? (float) atof(currentNode->Attribute("step")) : 0;
      float fMax   = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0;
      setting = new CSettingNumber(strKey, iLabelId, fValue, fMin, fStep, fMax);
    }
    else if (strSettingsType.Equals("enum"))
    {
      CStdString strEnums = XMLUtils::GetAttribute(currentNode, "lvalues");
      if (!strEnums.empty())
      {
        vector< pair<int,int> > enums;
        vector<std::string> valuesVec;
        StringUtils::Tokenize(strEnums, valuesVec, "|");
        for (unsigned int i = 0; i < valuesVec.size(); i++)
          enums.push_back(make_pair(atoi(valuesVec[i].c_str()), atoi(valuesVec[i].c_str())));
        int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
        setting = new CSettingInt(strKey, iLabelId, iValue, enums);
      }
    }
    else
    {
      CStdString strValue = XMLUtils::GetAttribute(currentNode, "value");
      setting = new CSettingString(strKey, iLabelId, strValue);
    }

    if (setting)
    {
      //TODO add more types if needed

      /* set the visibility */
      setting->SetVisible(bConfigurable);

      /* set the order */
      int iOrder = 0;
      currentNode->Attribute("order", &iOrder);
      /* if the order attribute is invalid or 0, then the setting will be added at the end */
      if (iOrder < 0)
        iOrder = 0;
      if (iOrder > iMaxOrder)
       iMaxOrder = iOrder;

      /* and add this new setting */
      PeripheralDeviceSetting deviceSetting = { setting, iOrder };
      settings[strKey] = deviceSetting;
    }

    currentNode = currentNode->NextSiblingElement("setting");
  }

  /* add the settings without an order attribute or an invalid order attribute set at the end */
  for (map<CStdString, PeripheralDeviceSetting>::iterator it = settings.begin(); it != settings.end(); ++it)
  {
    if (it->second.m_order == 0)
      it->second.m_order = ++iMaxOrder;
  }
}
开发者ID:7orlum,项目名称:xbmc,代码行数:89,代码来源:Peripherals.cpp

示例12: SetFileItemMetaData

void CMythSession::SetFileItemMetaData(CFileItem &item, cmyth_proginfo_t program)
{
  if (!program)
    return;

  /*
   * Set the FileItem meta-data.
   */
  CStdString title        = GetValue(m_dll->proginfo_title(program)); // e.g. Mythbusters
  CStdString subtitle     = GetValue(m_dll->proginfo_subtitle(program)); // e.g. The Pirate Special
  item.m_strTitle         = title;
  if (!subtitle.empty())
    item.m_strTitle      += " - \"" + subtitle + "\""; // e.g. Mythbusters - "The Pirate Special"
  item.m_dateTime         = GetValue(m_dll->proginfo_rec_start(program));
  item.m_dwSize           = m_dll->proginfo_length(program); // size in bytes

  /*
   * Set the VideoInfoTag meta-data so it matches the FileItem meta-data where possible.
   */
  CVideoInfoTag* tag      = item.GetVideoInfoTag();
  tag->m_strTitle         = subtitle; // The title is just supposed to be the episode title.
  tag->m_strShowTitle     = title;
  tag->m_strOriginalTitle = title;
  tag->m_strPlotOutline   = subtitle;
  tag->m_strPlot          = GetValue(m_dll->proginfo_description(program));
  /*
   * TODO: Strip out the subtitle from the description if it is present at the start? OR add the
   * subtitle to the start of the plot if not already as it used to? Seems strange, should be
   * handled by skin?
   *
  if (tag->m_strPlot.Left(tag->m_strPlotOutline.length()) != tag->m_strPlotOutline && !tag->m_strPlotOutline.empty())
    tag->m_strPlot = tag->m_strPlotOutline + '\n' + tag->m_strPlot;
   */
  tag->m_genre            = StringUtils::Split(GetValue(m_dll->proginfo_category(program)), g_advancedSettings.m_videoItemSeparator); // e.g. Sports
  tag->m_strAlbum         = GetValue(m_dll->proginfo_chansign(program)); // e.g. TV3
  tag->m_duration         = m_dll->proginfo_length_sec(program);
  
  SetSeasonAndEpisode(program, &tag->m_iSeason, &tag->m_iEpisode);

  /*
   * Original air date is used by the VideoInfoScanner to scrape the TV Show information into the
   * Video Library. If the original air date is empty the date returned will be the epoch.
   */
  CStdString originalairdate = GetValue(m_dll->proginfo_originalairdate(program)).GetAsDBDate();
  if (originalairdate != "1970-01-01"
  &&  originalairdate != "1969-12-31")
  tag->m_firstAired.SetFromDateString(originalairdate);

  /*
   * Video sort title is the raw title with the date appended on the end in a sortable format so
   * when the "All Recordings" listing is sorted by "Name" rather than "Date", all of the episodes
   * for a given show are still presented in date order (even though some may have a subtitle that
   * would cause it to be shown in a different position if it was indeed strictly sorting by
   * what is displayed in the list).
   */
  tag->m_strSortTitle = title + " " + item.m_dateTime.GetAsDBDateTime(); // e.g. Mythbusters 2009-12-13 12:23:14

  /*
   * Set further FileItem and VideoInfoTag meta-data based on whether it is LiveTV or not.
   */
  CURL url(item.GetPath());
  if (StringUtils::StartsWith(url.GetFileName(), "channels/"))
  {
    /*
     * Prepend the channel number onto the FileItem title for the listing so it's clear what is
     * playing on each channel without using up as much room as the channel name.
     */
    CStdString number = GetValue(m_dll->proginfo_chanstr(program));
    item.m_strTitle = number + " - " + item.m_strTitle;

    /*
     * Append the channel name onto the end of the tag title for the OSD so it's clear what LiveTV
     * channel is currently being watched to give some context for Next or Previous channel. Added
     * to the end so sorting by title will work, and it's not really as important as the title
     * within the OSD.
     */
    CStdString name = GetValue(m_dll->proginfo_chansign(program));
    if (!name.empty())
      tag->m_strTitle += " - " + name;

    /*
     * Set the sort title to be the channel number.
     */
    tag->m_strSortTitle = number;

    /*
     * Set the status so XBMC treats the content as LiveTV.
     */
    tag->m_strStatus = "livetv";

    /*
     * Update the path and channel icon for LiveTV in case the channel has changed through
     * NextChannel(), PreviousChannel() or SetChannel().
     */
    if (!number.empty())
    {
      url.SetFileName("channels/" + number + ".ts"); // e.g. channels/3.ts
      item.SetPath(url.Get());
    }
    CStdString chanicon = GetValue(m_dll->proginfo_chanicon(program));
//.........这里部分代码省略.........
开发者ID:Anankin,项目名称:xbmc,代码行数:101,代码来源:MythSession.cpp

示例13: HandleFileItem

void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant &parameterObject, const CVariant &validFields, CVariant &result, bool append /* = true */)
{
  CVariant object;
  bool hasFileField = false;
  bool hasThumbnailField = false;

  if (item.get())
  {
    for (unsigned int i = 0; i < validFields.size(); i++)
    {
      CStdString field = validFields[i].asString();

      if (field == "file")
        hasFileField = true;
      if (field == "thumbnail")
        hasThumbnailField = true;
    }

    if (allowFile && hasFileField)
    {
      if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().IsEmpty())
          object["file"] = item->GetVideoInfoTag()->GetPath().c_str();
      if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().IsEmpty())
        object["file"] = item->GetMusicInfoTag()->GetURL().c_str();

      if (!object.isMember("file"))
        object["file"] = item->GetPath().c_str();
    }

    if (ID)
    {
      if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0)
        object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId();
      else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0)
        object[ID] = item->GetVideoInfoTag()->m_iDbId;

      if (stricmp(ID, "id") == 0)
      {
        if (item->HasMusicInfoTag())
        {
          if (item->m_bIsFolder && item->IsAlbum())
            object["type"] = "album";
          else
            object["type"] = "song";
        }
        else if (item->HasVideoInfoTag())
        {
          switch (item->GetVideoContentType())
          {
            case VIDEODB_CONTENT_EPISODES:
              object["type"] = "episode";
              break;

            case VIDEODB_CONTENT_MUSICVIDEOS:
              object["type"] = "musicvideo";
              break;

            case VIDEODB_CONTENT_MOVIES:
              object["type"] = "movie";
              break;

            default:
              break;
          }
        }
        else if (item->HasPictureInfoTag())
          object["type"] = "picture";

        if (!object.isMember("type"))
          object["type"] = "unknown";
      }
    }

    if (hasThumbnailField)
    {
      if (item->HasThumbnail())
        object["thumbnail"] = item->GetThumbnailImage().c_str();
      else if (item->HasVideoInfoTag())
      {
        CStdString strPath, strFileName;
        URIUtils::Split(item->GetCachedVideoThumb(), strPath, strFileName);
        CStdString cachedThumb = strPath + "auto-" + strFileName;

        if (CFile::Exists(cachedThumb))
          object["thumbnail"] = cachedThumb;
      }
      else if (item->HasPictureInfoTag())
      {
        CStdString thumb = CTextureCache::Get().CheckAndCacheImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
        if (!thumb.empty())
          object["thumbnail"] = thumb;
      }

      if (!object.isMember("thumbnail"))
        object["thumbnail"] = "";
    }

    if (item->HasVideoInfoTag())
      FillDetails(item->GetVideoInfoTag(), item, validFields, object);
    if (item->HasMusicInfoTag())
//.........这里部分代码省略.........
开发者ID:Shadowmeph,项目名称:xbmc,代码行数:101,代码来源:FileItemHandler.cpp

示例14: SetSeasonAndEpisode

void CMythSession::SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *season, int *episode) {
  /*
   * A valid programid generated from an XMLTV source should look like:
   * [EP|MV|SH|SP][seriesid][episode][season]([partnumber][parttotal])
   * mythtv/trunk/programs/mytfilldatabaseline/xmltvparser.cpp - Line 522 onwards.
   * 
   * Season changed to a base36 character for XMLTV in Myth 0.24. http://svn.mythtv.org/trac/changeset/24724
   * 
   * A valid SchedulesDirect programid appears to have a similar format to the XMLTV programid but
   * doesn't have any obvious way to parse out the season and episode information. The number at the
   * end of the programid could possibly be the completely sequential number for the episode, but
   * even that doesn't seem to match up with TVDB. SchedulesDirect data does seem to have a valid
   * original air date though, so if we identify a SchedulesDirect programid, leave the season and
   * episode as 0. 
   */
  CStdString programid = GetValue(m_dll->proginfo_programid(program));
  CStdString seriesid = GetValue(m_dll->proginfo_seriesid(program));

  /*
   * Default the season and episode to 0 so XBMC treats the content as an episode and displays tag
   * information. If the season and episode can be parsed from the programid these will be
   * overwritten.
   */
  *season  = 0;
  *episode = 0;
  
  if (programid.empty() // Can't do anything if the program ID is empty
  ||  seriesid.empty()) // Can't figure out the end parsing if the series ID is empty  {
    return;
  
  CStdString category = programid.substr(0, 2); // Valid for both XMLTV and SchedulesDirect sources
  if (category != "MV"  // Movie
  &&  category != "EP"  // Series
  &&  category != "SH"  // TV Show
  &&  category != "SP") // Sports
    return;
  
  if (programid.substr(category.length(), seriesid.length()) != seriesid) // Series ID does not follow the category
    return;
  
  CStdString remainder = programid.substr(category.length() + seriesid.length()); // Whatever is after series ID
  
  /*
   * All SchedulesDirect remainders appear to be 4 characters and start with a 0. If the assumption
   * is correct that the number somehow relates to the sequential episode number across all seasons
   * then we can ignore remainders that start with 0. It will be very unlikely for a sequential
   * episode number for a series to be > 999.
   */
  if (remainder.length() == 4     // All SchedulesDirect codes seem to be 4 characters
  &&  remainder[0] == '0')        // Padded with 0's for low number. No valid XMLTV remainder will start with 0.
    return;
  
  /*
   * If the remainder is more than 5 characters, it must include the optional part number and total
   * number of parts. Strip off the last 2 characters assuming that there are ridiculously few
   * cases where the number of parts for a single episode is > 9.
   */
  if (remainder.length() >= 5) // Must include optional part number and total number of parts
    remainder = remainder.substr(0, remainder.length() - 2); // Assumes part number and total are both < 10

  /*
   * Now for some heuristic black magic.
   */
  if (remainder.length() == 2)  // Single character season and episode.
  {
    *season = atoi(remainder.substr(1, 1).c_str()); // TODO: Fix for base 36 in Myth 0.24. Assume season < 10
    *episode = atoi(remainder.substr(0, 1).c_str());
  }
  else if (remainder.length() == 3) // Ambiguous in Myth 0.23. Single character season in Myth 0.24
  {
    /*
     * Following heuristics are intended to work with largest possible number of cases. It won't be
     * perfect, but way better than just assuming the season is < 10.
     */
    if (remainder[2] == '0') // e.g. 610. Unlikely to have a season of 0 (specials) with more than 9 special episodes.
    {
      *season = atoi(remainder.substr(1, 2).c_str());
      *episode = atoi(remainder.substr(0, 1).c_str());
    }
    else if (remainder[1] == '0') // e.g. 203. Can't have a season start with 0. Must be end of episode.
    {
      *season = atoi(remainder.substr(2, 1).c_str()); // TODO: Fix for base 36 in Myth 0.24. Assume season < 10
      *episode = atoi(remainder.substr(0, 2).c_str());
    }
    else if (atoi(remainder.substr(0, 1).c_str()) > 3) // e.g. 412. Very unlikely to have more than 39 episodes per season if season > 9.
    {
      /*
       * TODO: See if a check for > 2 is better, e.g. is it still unlike to have more than 29 episodes
       * per season if season > 9?
       */
      *season = atoi(remainder.substr(1, 2).c_str());
      *episode = atoi(remainder.substr(0, 1).c_str());
    }
    else // e.g. 129. Assume season is < 10 or Myth 0.24 Base 36 season.
    {
      *season = atoi(remainder.substr(2, 1).c_str()); // TODO: Fix for base 36 in Myth 0.24. Assume season < 10
      *episode = atoi(remainder.substr(0, 2).c_str());
    }
  }
  else if (remainder.length() == 4) // Double digit season and episode in Myth 0.23 OR TODO: has part number and total number of parts
//.........这里部分代码省略.........
开发者ID:Anankin,项目名称:xbmc,代码行数:101,代码来源:MythSession.cpp

示例15: getFieldFromString

bool CAirPlayServer::CTCPClient::checkAuthorization(const CStdString& authStr,
                                                    const CStdString& method,
                                                    const CStdString& uri)
{
  bool authValid = true;

  CStdString username;

  if (authStr.empty())
    return false;

  //first get username - we allow all usernames for airplay (usually it is AirPlay)
  username = getFieldFromString(authStr, "username");
  if (username.empty())
  {
    authValid = false;
  }

  //second check realm
  if (authValid)
  {
    if (getFieldFromString(authStr, "realm") != AUTH_REALM)
    {
      authValid = false;
    }
  }

  //third check nonce
  if (authValid)
  {
    if (getFieldFromString(authStr, "nonce") != m_authNonce)
    {
      authValid = false;
    }
  }

  //forth check uri
  if (authValid)
  {
    if (getFieldFromString(authStr, "uri") != uri)
    {
      authValid = false;
    }
  }

  //last check response
  if (authValid)
  {
     CStdString realm = AUTH_REALM;
     CStdString ourResponse = calcResponse(username, ServerInstance->m_password, realm, method, uri, m_authNonce);
     CStdString theirResponse = getFieldFromString(authStr, "response");
     if (!theirResponse.Equals(ourResponse, false))
     {
       authValid = false;
       CLog::Log(LOGDEBUG,"AirAuth: response mismatch - our: %s theirs: %s",ourResponse.c_str(), theirResponse.c_str());
     }
     else
     {
       CLog::Log(LOGDEBUG, "AirAuth: successfull authentication from AirPlay client");
     }
  }
  m_bAuthenticated = authValid;
  return m_bAuthenticated;
}
开发者ID:Pivosgroup,项目名称:xbmc,代码行数:64,代码来源:AirPlayServer.cpp


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