Example #1
0
CSFTPSessionPtr CSFTPSessionManager::CreateSession(const CURL &url)
{
  string username = url.GetUserName().c_str();
  string password = url.GetPassWord().c_str();
  string hostname = url.GetHostName().c_str();
  unsigned int port = url.HasPort() ? url.GetPort() : 22;

  return CSFTPSessionManager::CreateSession(hostname, port, username, password);
}
Example #2
0
bool CMythSession::CanSupport(const CURL& url)
{
  if (m_hostname != url.GetHostName())
    return false;

  if (m_port != (url.HasPort() ? url.GetPort() : MYTH_DEFAULT_PORT))
    return false;

  if (m_username != (url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName()))
    return false;

  if (m_password != (url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord()))
    return false;

  return true;
}
Example #3
0
std::string CSMB::URLEncode(const CURL &url)
{
  /* due to smb wanting encoded urls we have to build it manually */

  std::string flat = "smb://";

  /* samba messes up of password is set but no username is set. don't know why yet */
  /* probably the url parser that goes crazy */
  if(url.GetUserName().length() > 0 /* || url.GetPassWord().length() > 0 */)
  {
    if(!url.GetDomain().empty())
    {
      flat += URLEncode(url.GetDomain());
      flat += ";";
    }
    flat += URLEncode(url.GetUserName());
    if(url.GetPassWord().length() > 0)
    {
      flat += ":";
      flat += URLEncode(url.GetPassWord());
    }
    flat += "@";
  }
  flat += URLEncode(url.GetHostName());

  if (url.HasPort())
  {
    flat += StringUtils::Format(":%i", url.GetPort());
  }

  /* okey sadly since a slash is an invalid name we have to tokenize */
  std::vector<std::string> parts;
  std::vector<std::string>::iterator it;
  StringUtils::Tokenize(url.GetFileName(), parts, "/");
  for( it = parts.begin(); it != parts.end(); ++it )
  {
    flat += "/";
    flat += URLEncode((*it));
  }

  /* okey options should go here, thou current samba doesn't support any */

  return flat;
}
Example #4
0
//*********************************************************************************************
bool CDAAPFile::Open(const CURL& url)
{
  CSingleLock lock(g_DaapClient);

  if (m_bOpened) Close();

  m_url = url;

  CLog::Log(LOGDEBUG, "CDAAPFile::Open(%s)", url.GetFileName().c_str());
  CStdString host = url.GetHostName();
  if (url.HasPort())
    host.Format("%s:%i",url.GetHostName(),url.GetPort());
  m_thisHost = g_DaapClient.GetHost(host);
  if (!m_thisHost)
    return false;

  /* get us a new request id */
  int requestid = ++m_thisHost->request_id;

  m_hashurl = "/" + m_url.GetFileName();
  m_hashurl += m_url.GetOptions();

  char hash[33] = {0};
  GenerateHash(m_thisHost->version_major, (unsigned char*)(m_hashurl.c_str()), 2, (unsigned char*)hash, requestid);

  m_curl.SetUserAgent(DAAP_USERAGENT);

  //m_curl.SetRequestHeader(HEADER_VERSION, "3.0");
  m_curl.SetRequestHeader(HEADER_REQUESTID, requestid);
  m_curl.SetRequestHeader(HEADER_VALIDATE, CStdString(hash));
  m_curl.SetRequestHeader(HEADER_ACCESS_INDEX, 2);

  m_url.SetProtocol("http");
  if(!m_url.HasPort())
    m_url.SetPort(DAAP_PORT);


  m_bOpened = true;

  return m_curl.Open(m_url);
}
Example #5
0
bool CHTSPDirectorySession::Open(const CURL& url)
{
  if(!m_session.Connect(url.GetHostName(), url.GetPort()))
    return false;

  if(m_session.GetProtocol() < 2)
  {
    CLog::Log(LOGERROR, "CHTSPDirectory::GetDirectory - incompatible protocol version %d", m_session.GetProtocol());
    return false;
  }

  if(!url.GetUserName().empty())
    m_session.Auth(url.GetUserName(), url.GetPassWord());

  if(!m_session.SendEnableAsync())
    return false;

  Create();

  m_started.WaitMSec(30000);
  return !m_bStop;
}
Example #6
0
    CVFSURLWrapper(const CURL& url2)
    {
      m_strings.push_back(url2.Get());
      m_strings.push_back(url2.GetDomain());
      m_strings.push_back(url2.GetHostName());
      m_strings.push_back(url2.GetFileName());
      m_strings.push_back(url2.GetOptions());
      m_strings.push_back(url2.GetUserName());
      m_strings.push_back(url2.GetPassWord());
      m_strings.push_back(url2.GetRedacted());
      m_strings.push_back(url2.GetShareName());

      url.url = m_strings[0].c_str();
      url.domain = m_strings[1].c_str();
      url.hostname = m_strings[2].c_str();
      url.filename = m_strings[3].c_str();
      url.port = url2.GetPort();
      url.options = m_strings[4].c_str();
      url.username = m_strings[5].c_str();
      url.password = m_strings[6].c_str();
      url.redacted = m_strings[7].c_str();
      url.sharename = m_strings[8].c_str();
    }
Example #7
0
CMythSession::CMythSession(const CURL& url)
{
  m_control   = NULL;
  m_event     = NULL;
  m_database  = NULL;
  m_hostname  = url.GetHostName();
  m_username  = url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName();
  m_password  = url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord();
  m_port      = url.HasPort() ? url.GetPort() : MYTH_DEFAULT_PORT;
  m_timestamp = CTimeUtils::GetTimeMS();
  m_dll = new DllLibCMyth;
  m_dll->Load();
  if (m_dll->IsLoaded())
  {
    if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG_SAMBA)
      m_dll->dbg_level(CMYTH_DBG_ALL);
    else if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG)
      m_dll->dbg_level(CMYTH_DBG_DETAIL);
    else
      m_dll->dbg_level(CMYTH_DBG_ERROR);
  }
  m_all_recorded = NULL;
}
Example #8
0
CMythSession::CMythSession(const CURL& url) : CThread("MythSession")
{
  m_control   = NULL;
  m_event     = NULL;
  m_database  = NULL;
  m_hostname  = url.GetHostName();
  m_username  = url.GetUserName() == "" ? MYTH_DEFAULT_USERNAME : url.GetUserName();
  m_password  = url.GetPassWord() == "" ? MYTH_DEFAULT_PASSWORD : url.GetPassWord();
  m_port      = url.HasPort() ? url.GetPort() : MYTH_DEFAULT_PORT;
  m_timestamp = XbmcThreads::SystemClockMillis();
  m_dll = new DllLibCMyth;
  m_dll->Load();
  if (m_dll->IsLoaded())
  {
    m_dll->set_dbg_msgcallback(&CMythSession::LogCMyth);
    if (g_advancedSettings.m_extraLogLevels & LOGCMYTH)
      m_dll->dbg_level(CMYTH_DBG_ALL);
    else if (g_advancedSettings.m_logLevel >= LOG_LEVEL_DEBUG)
      m_dll->dbg_level(CMYTH_DBG_DETAIL);
    else
      m_dll->dbg_level(CMYTH_DBG_ERROR);
  }
  m_all_recorded = NULL;
}
bool CSlingboxFile::Open(const CURL& url)
{
  // Setup the IP/hostname and port (setup default port if none specified)
  unsigned int uiPort;
  if (url.HasPort())
    uiPort = (unsigned int)url.GetPort();
  else
    uiPort = 5001;
  m_pSlingbox->SetAddress(url.GetHostName(), uiPort);

  // Prepare to connect to the Slingbox
  bool bAdmin;
  if (url.GetUserName().CompareNoCase("administrator") == 0)
    bAdmin = true;
  else if (url.GetUserName().CompareNoCase("viewer") == 0)
    bAdmin = false;
  else
  {
    CLog::Log(LOGERROR, "%s - Invalid or no username specified for Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
    return false;
  }

  // Connect to the Slingbox
  if (m_pSlingbox->Connect(bAdmin, url.GetPassWord()))
  {
    CLog::Log(LOGDEBUG, "%s - Successfully connected to Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
  }
  else
  {
    CLog::Log(LOGERROR, "%s - Error connecting to Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
    return false;
  }

  // Initialize the stream
  if (m_pSlingbox->InitializeStream())
  {
    CLog::Log(LOGDEBUG, "%s - Successfully initialized stream on Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
  }
  else
  {
    CLog::Log(LOGERROR, "%s - Error initializing stream on Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
    return false;
  }

  // Set correct input
  if (url.GetFileNameWithoutPath() != "")
  {
    if (m_pSlingbox->SetInput(atoi(url.GetFileNameWithoutPath())))
      CLog::Log(LOGDEBUG, "%s - Successfully requested change to input %i on Slingbox: %s",
        __FUNCTION__, atoi(url.GetFileNameWithoutPath()), url.GetHostName().c_str());
    else
      CLog::Log(LOGERROR, "%s - Error requesting change to input %i on Slingbox: %s",
        __FUNCTION__, atoi(url.GetFileNameWithoutPath()), url.GetHostName().c_str());
  }

  // Load the video settings
  LoadSettings(url.GetHostName());

  // Setup video options  
  if (m_pSlingbox->StreamSettings((CSlingbox::Resolution)m_sSlingboxSettings.iVideoResolution,
    m_sSlingboxSettings.iVideoBitrate, m_sSlingboxSettings.iVideoFramerate,
    m_sSlingboxSettings.iVideoSmoothing, m_sSlingboxSettings.iAudioBitrate,
    m_sSlingboxSettings.iIFrameInterval))
  {
    CLog::Log(LOGDEBUG, "%s - Successfully set stream options (resolution: %ix%i; "
      "video bitrate: %i kbit/s; fps: %i; smoothing: %i%%; audio bitrate %i kbit/s; "
      "I frame interval: %i) on Slingbox: %s", __FUNCTION__,
      m_sSlingboxSettings.iVideoWidth, m_sSlingboxSettings.iVideoHeight,
      m_sSlingboxSettings.iVideoBitrate, m_sSlingboxSettings.iVideoFramerate,
      m_sSlingboxSettings.iVideoSmoothing, m_sSlingboxSettings.iAudioBitrate,
      m_sSlingboxSettings.iIFrameInterval, url.GetHostName().c_str());
  }
  else
  {
    CLog::Log(LOGERROR, "%s - Error setting stream options on Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
  }

  // Start the stream
  if (m_pSlingbox->StartStream())
  {
    CLog::Log(LOGDEBUG, "%s - Successfully started stream on Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
  }
  else
  {
    CLog::Log(LOGERROR, "%s - Error starting stream on Slingbox: %s",
      __FUNCTION__, url.GetHostName().c_str());
    return false;
  }

  // Check for correct input
  if (url.GetFileNameWithoutPath() != "")
  {
    if (m_pSlingbox->GetInput() == -1)
      CLog::Log(LOGDEBUG, "%s - Unable to confirm change to input %i on Slingbox: %s",
        __FUNCTION__, atoi(url.GetFileNameWithoutPath()), url.GetHostName().c_str());
    else if (m_pSlingbox->GetInput() == atoi(url.GetFileNameWithoutPath()))
      CLog::Log(LOGDEBUG, "%s - Comfirmed change to input %i on Slingbox: %s",
        __FUNCTION__, atoi(url.GetFileNameWithoutPath()), url.GetHostName().c_str());
    else
      CLog::Log(LOGERROR, "%s - Error changing to input %i on Slingbox: %s",
        __FUNCTION__, atoi(url.GetFileNameWithoutPath()), url.GetHostName().c_str());
  }

  return true;
}
Example #10
0
bool CRTVFile::Open(const CURL& url)
{
  return Open(url.GetHostName(), url.GetFileName(), url.GetPort());
}
Example #11
0
bool CRTVFile::Open(const CURL& url)
{
  return Open((CStdString)url.GetHostName(), (CStdString)url.GetFileName(), url.GetPort());
}