1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NET_HTTP_PROXY_TRACKER_H 17 #define NET_HTTP_PROXY_TRACKER_H 18 #include "net_proxy_userinfo.h" 19 #include "http_proxy.h" 20 #include "uri.h" 21 22 namespace OHOS { 23 namespace NetManagerStandard { 24 class NetHttpProxyTracker { 25 public: 26 NetHttpProxyTracker() = default; 27 ~NetHttpProxyTracker() = default; 28 29 void ReadFromSettingsData(HttpProxy &httpProxy); 30 bool WriteToSettingsData(HttpProxy &httpProxy); 31 32 void ReadFromSettingsDataUser(HttpProxy &httpProxy, int32_t userId); 33 bool WriteToSettingsDataUser(HttpProxy &httpProxy, int32_t userId); 34 35 private: 36 struct KeyUri { 37 Uri hostUri_; 38 Uri portUri_; 39 Uri exclusionsUri_; 40 }; 41 42 private: 43 std::list<std::string> ParseExclusionList(const std::string &exclusions) const; 44 std::string GetExclusionsAsString(const std::list<std::string> &exclusionList) const; 45 void ReadFromSettingsData(HttpProxy &httpProxy, KeyUri keyUri); 46 bool WriteToSettingsData(HttpProxy &httpProxy, KeyUri keyUri); 47 std::string ReplaceUserIdForUri(const char* uri, int32_t userId); 48 }; 49 } // namespace NetManagerStandard 50 } // namespace OHOS 51 #endif // NET_HTTP_PROXY_TRACKER_H