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


C++ CPVRDatabase::Persist方法代码示例

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


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

示例1: RegisterClient

int CPVRClients::RegisterClient(AddonPtr client, bool* newRegistration/*=NULL*/)
{
  int iClientId(-1);

  if (newRegistration)
    *newRegistration = false;

  if (!client->Enabled())
    return -1;

  CLog::Log(LOGDEBUG, "%s - registering add-on '%s'", __FUNCTION__, client->Name().c_str());

  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return -1;

  // check whether we already know this client
  iClientId = database->GetClientId(client->ID());

  // try to register the new client in the db
  if (iClientId < 0)
  {
    if ((iClientId = database->Persist(client)) < 0)
    {
      CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, client->Name().c_str());
      return -1;
    }
    else if (newRegistration)
      *newRegistration = true;
  }

  PVR_CLIENT addon;
  // load and initialise the client libraries
  {
    CSingleLock lock(m_critSection);
    PVR_CLIENTMAP_CITR existingClient = m_clientMap.find(iClientId);
    if (existingClient != m_clientMap.end())
    {
      // return existing client
      addon = existingClient->second;
    }
    else
    {
      // create a new client instance
      addon = boost::dynamic_pointer_cast<CPVRClient>(client);
      m_clientMap.insert(std::make_pair(iClientId, addon));
    }
  }

  if (iClientId < 0)
    CLog::Log(LOGERROR, "PVR - %s - can't register add-on '%s'", __FUNCTION__, client->Name().c_str());

  return iClientId;
}
开发者ID:Sithisackt,项目名称:kodi,代码行数:54,代码来源:PVRClients.cpp

示例2: Persist

bool CPVRChannel::Persist(bool bQueueWrite /* = false */)
{
  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (database)
  {
    if (!bQueueWrite)
    {
      database->Open();
      m_iChannelId = database->Persist(*this, false);
      database->Close();
      return m_iChannelId > 0;
    }
    else
    {
      database->Persist(*this, true);
      return true;
    }
  }

  return false;
}
开发者ID:rdaoc,项目名称:xbmc,代码行数:21,代码来源:PVRChannel.cpp

示例3: AddClientToDb

int CPVRClients::AddClientToDb(const AddonPtr client)
{
  /* add this client to the database if it's not in there yet */
  CPVRDatabase *database = GetPVRDatabase();
  int iClientDbId = database ? database->Persist(client) : -1;
  if (iClientDbId == -1)
  {
    CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database",
        __FUNCTION__, client->Name().c_str());
  }

  return iClientDbId;
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例4: Persist

bool CPVRChannelGroup::Persist(void)
{
  CSingleLock lock(m_critSection);
  if (!HasChanges())
    return true;

  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (database && database->Open())
  {
    CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - persisting channel group '%s' with %d channels",
        __FUNCTION__, GroupName().c_str(), (int) size());
    database->Persist(this);
    database->Close();

    m_bChanged = false;
    return true;
  }

  return false;
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例5: OnMessage


//.........这里部分代码省略.........
        pDialog->SetLine(0, "");
        pDialog->SetLine(1, 750);
        pDialog->SetLine(2, "");
        pDialog->DoModal();

        if (pDialog->IsConfirmed())
        {
          if (pItem->GetPropertyBOOL("Virtual"))
          {
            CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
            database->Open();
            database->Delete(*pItem->GetPVRChannelInfoTag());
            database->Close();

            m_channelItems->Remove(m_iSelected);
            m_viewControl.SetItems(*m_channelItems);
            Renumber();
            return true;
          }
          CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
        }
        return true;
      }
      else if (iControl == BUTTON_NEW_CHANNEL)
      {
        std::vector<long> clients;

        CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
        if (!pDlgSelect)
          return false;

        pDlgSelect->SetHeading(19213); // Select Client
        pDlgSelect->Add(g_localizeStrings.Get(19209));
        clients.push_back(XBMC_VIRTUAL_CLIENTID);

        std::map<long, CStdString> clientMap;
        if (CPVRManager::GetClients()->GetClients(&clientMap) > 0)
        {
          std::map<long,CStdString>::iterator itr;
          for (itr = clientMap.begin() ; itr != clientMap.end(); itr++)
          {
            clients.push_back((*itr).first);
            pDlgSelect->Add(clientMap[(*itr).first]);
          }
        }
        pDlgSelect->DoModal();

        int selection = pDlgSelect->GetSelectedLabel();
        if (selection >= 0 && selection <= (int) clients.size())
        {
          int clientID = clients[selection];
          if (clientID == XBMC_VIRTUAL_CLIENTID)
          {
            CStdString strURL = "";
            if (CGUIDialogKeyboard::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false))
            {
              if (!strURL.IsEmpty())
              {
                CPVRChannel newchannel(m_bIsRadio);
                newchannel.SetChannelName(g_localizeStrings.Get(19204));
                newchannel.SetEPGEnabled(false);
                newchannel.SetVirtual(true);
                newchannel.SetStreamURL(strURL);
                newchannel.SetClientID(XBMC_VIRTUAL_CLIENTID);

                CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
                database->Open();
                database->Persist(newchannel);
                database->Close();
                CFileItemPtr channel(new CFileItem(newchannel));

                if (channel)
                {
                  channel->SetProperty("ActiveChannel", true);
                  channel->SetProperty("Name", g_localizeStrings.Get(19204));
                  channel->SetProperty("UseEPG", false);
                  channel->SetProperty("Icon", newchannel.IconPath());
                  channel->SetProperty("EPGSource", (int)0);
                  channel->SetProperty("ClientName", g_localizeStrings.Get(19209));

                  m_channelItems->AddFront(channel, m_iSelected);
                  m_viewControl.SetItems(*m_channelItems);
                  Renumber();
                }
              }
            }
          }
          else
          {
            CGUIDialogOK::ShowAndGetInput(19033,19038,0,0);
          }
        }
        return true;
      }
    }
    break;
  }

  return CGUIDialog::OnMessage(message);
}
开发者ID:,项目名称:,代码行数:101,代码来源:


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