LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
lcserviceoverride.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "lcserviceoverride.h"
10 
11 namespace LC::Util
12 {
13  namespace
14  {
15  QString GetHost (const ServiceInfo& info)
16  {
17  static const auto& env = qgetenv (info.EnvPrefix_ + "_SERVER_HOST");
18  if (!env.isEmpty ())
19  return env;
20 
21  return info.DefaultHost_;
22  }
23 
24  int GetPort (const ServiceInfo& info)
25  {
26  static const auto& env = qgetenv (info.EnvPrefix_ + "_SERVER_PORT");
27  if (!env.isEmpty ())
28  return env.toInt ();
29 
30  return info.DefaultPort_;
31  }
32 
33  QString GetProto (const ServiceInfo& info)
34  {
35  static const auto& env = qgetenv (info.EnvPrefix_ + "_NO_HTTPS");
36  return env.isEmpty () && info.UseSslByDefault_ ? QStringLiteral ("https") : QStringLiteral ("http");
37  }
38  }
39 
40  QString GetServiceUrl (const ServiceInfo& info, const QString& path)
41  {
42  return QStringLiteral ("%1://%2:%3/%4")
43  .arg (GetProto (info),
44  GetHost (info))
45  .arg (GetPort (info))
46  .arg (path);
47  }
48 }
lcserviceoverride.h
LC::Util
Definition: icoreproxy.h:33
LC::Util::GetServiceUrl
QString GetServiceUrl(const ServiceInfo &info, const QString &path)
Definition: lcserviceoverride.cpp:46