QString SystemComponent::debugInformation()
{
  QString debugInfo;
  QTextStream stream(&debugInfo);

  stream << "Plex Media Player" << endl;
  stream << "  Version: " << Version::GetVersionString() << " built: " << Version::GetBuildDate() << endl;
  stream << "  Web Client Version: " << Version::GetWebVersion() << endl;
  stream << "  Platform: " << getPlatformTypeString() << "-" << getPlatformArchString() << endl;
  stream << "  User-Agent: " << getUserAgent() << endl;
  stream << "  Qt version: " << qVersion() << endl;
  stream << endl;

  stream << "Files" << endl;
  stream << "  Log file: " << Paths::logDir(Names::MainName() + ".log") << endl;
  stream << "  Config file: " << Paths::dataDir(Names::MainName() + ".conf") << endl;
  stream << endl;

#ifdef Q_OS_UNIX
  stream << "Network" << endl;
  QMap<QString, QString> networks = networkInterfaces();
  foreach(const QString& net, networks.keys())
    stream << "  " << net << ": " << networks[net] << endl;
#endif

  stream << flush;
  return debugInfo;
}
QString SystemComponent::debugInformation()
{
  QString debugInfo;
  QTextStream stream(&debugInfo);

  stream << "Plex Media Player" << endl;
  stream << "  Version: " << Version::GetVersionString() << " built: " << Version::GetBuildDate() << endl;
  stream << "  Web Client Version: " << Version::GetWebVersion() << endl;
  stream << "  Web Client URL: " << SettingsComponent::Get().value(SETTINGS_SECTION_PATH, "startupurl").toString() << endl;
  stream << "  Platform: " << getPlatformTypeString() << "-" << getPlatformArchString() << endl;
  stream << "  User-Agent: " << getUserAgent() << endl;
  stream << "  Qt version: " << qVersion() << endl;
  stream << endl;

  stream << "Files" << endl;
  stream << "  Log file: " << Paths::logDir(Names::MainName() + ".log") << endl;
  stream << "  Config file: " << Paths::dataDir(Names::MainName() + ".conf") << endl;
  stream << endl;

  stream << "Network Addresses" << endl;
  foreach (const QString& addr, networkAddresses())
  {
    stream << "  " << addr << endl;
  }
  stream << endl;

  stream << flush;
  return debugInfo;
}
QVariantMap SystemComponent::systemInformation() const
{
  QVariantMap info;
  QString build;
  QString dist;
  QString arch;
  int productid = KONVERGO_PRODUCTID_DEFAULT;

#ifdef Q_OS_WIN
  arch = "x86_64";
#else
  arch = QSysInfo::currentCpuArchitecture();
#endif

  build = getPlatformTypeString();
  dist = getPlatformTypeString();

#if defined(KONVERGO_OPENELEC)
  productid = KONVERGO_PRODUCTID_OPENELEC;
  dist = "openelec";

  if (m_platformArch == platformArchRpi2)
  {
    build = "rpi2";
  }
  else
  {
    build = "generic";
  }
#endif

  
  info["build"] = build + "-" + arch;
  info["dist"] = dist;
  info["version"] = Version::GetVersionString();
  info["productid"] = productid;
  
 QLOG_DEBUG() << QString(
                "System Information : build(%1)-arch(%2).dist(%3).version(%4).productid(%5)")
                .arg(build)
                .arg(arch)
                .arg(dist)
                .arg(Version::GetVersionString())
                .arg(productid);
 return info;
}
QString SystemComponent::getUserAgent()
{
  QString userAgent = QString("Konvergo-%1-%2 %3").arg(getPlatformTypeString())
                                                       .arg(getPlatformArchString())
                                                       .arg(Version::GetVersionString());
  if (m_platformModfiers.size())
    userAgent += QString(" (%1)").arg(m_platformModfiers.join(','));

  return userAgent;
}
QString SystemComponent::getUserAgent()
{
  QString osVersion = QSysInfo::productVersion();
  QString userAgent = QString("PlexMediaPlayer %1 (%2-%3 %4)").arg(Version::GetVersionString()).arg(getPlatformTypeString()).arg(getPlatformArchString()).arg(osVersion);
  return userAgent;
}