Welcome to mirror list, hosted at ThFree Co, Russian Federation.

network_policy.hpp « platform - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e48ad3daa9d5282bd9a214888fb4c976bd6e9e64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "std/function.hpp"

class _jobject;
typedef _jobject * jobject;

namespace platform
{
class NetworkPolicy;
using PartnersApiFn = function<void(NetworkPolicy const & canUseNetwork)>;
}

namespace network_policy
{
void CallPartnersApi(platform::PartnersApiFn fn, bool force);
}

namespace platform
{
/// Class that is used to allow or disallow remote calls.
class NetworkPolicy
{
  // Maker for android.
  friend NetworkPolicy ToNativeNetworkPolicy(jobject obj);

  // iOS
  friend void network_policy::CallPartnersApi(platform::PartnersApiFn fn, bool force);

public:
  enum class Stage
  {
    Always,
    Session,
    Never
  };

  bool CanUse() const { return m_canUse; }

private:
  NetworkPolicy(bool const canUseNetwork) : m_canUse(canUseNetwork) {}

  bool m_canUse = false;
};
}  // namespace platform