diff --git a/main.cpp b/main.cpp index 680eea2..3810ca4 100644 --- a/main.cpp +++ b/main.cpp @@ -345,7 +345,7 @@ void VoIP::parseConfig() if (self["configuration"]["shared_config"]) { Php::Value shared_config = self["configuration"]["shared_config"]; - ServerConfig::GetSharedInstance()->Update(Php::call("json_encode", Php::call("array_merge", VoIPServerConfig::getDefault(), shared_config))); + ServerConfig::GetSharedInstance()->Update(Php::call("json_encode", Php::call("array_merge", Php::call("\\danog\\MadelineProto\\VoIPServerConfig::getFinal"), shared_config))); } inst->SetConfig(cfg); @@ -551,32 +551,11 @@ Php::Value VoIP::isPlaying() return playing; } -void VoIPServerConfig::update(Php::Parameters ¶ms) +void VoIPServerConfigInternal::update(Php::Parameters ¶ms) { - Php::Value copyCustom = params[0]; - config = copyCustom; - - ServerConfig::GetSharedInstance()->Update(Php::call("json_encode", Php::call("array_merge", configDefault, config))); + Php::Array settings = params[0]; + ServerConfig::GetSharedInstance()->Update(Php::call("json_encode", settings)); } - -Php::Value VoIPServerConfig::get() -{ - return config; -} - -void VoIPServerConfig::updateDefault(Php::Parameters ¶ms) -{ - Php::Value copyDefault = params[0]; - configDefault = copyDefault; - - ServerConfig::GetSharedInstance()->Update(Php::call("json_encode", Php::call("array_merge", configDefault, config))); -} - -Php::Value VoIPServerConfig::getDefault() -{ - return configDefault; -} - extern "C" { @@ -593,12 +572,8 @@ extern "C" // for the entire duration of the process (that's why it's static) static Php::Extension extension("php-libtgvoip", "1.1.2"); - - Php::Class voipServerConfig("VoIPServerConfig"); - voipServerConfig.method<&VoIPServerConfig::update>("update", Php::Public); - voipServerConfig.method<&VoIPServerConfig::get>("get", Php::Public); - voipServerConfig.method<&VoIPServerConfig::updateDefault>("updateDefault", Php::Public); - voipServerConfig.method<&VoIPServerConfig::getDefault>("getDefault", Php::Public); + Php::Class voipServerConfigInternal("VoIPServerConfigInternal"); + voipServerConfigInternal.method<&VoIPServerConfigInternal::update>("updateInternal", Php::Protected | Php::Static, {Php::ByVal("config", Php::Type::Array)}); // description of the class so that PHP knows which methods are accessible Php::Class voip("VoIP"); @@ -710,7 +685,7 @@ extern "C" Php::Namespace danog("danog"); Php::Namespace MadelineProto("MadelineProto"); - MadelineProto.add(move(voipServerConfig)); + MadelineProto.add(move(voipServerConfigInternal)); MadelineProto.add(move(voip)); danog.add(move(MadelineProto)); extension.add(move(danog)); diff --git a/main.h b/main.h index 54a24f2..710351c 100644 --- a/main.h +++ b/main.h @@ -73,16 +73,10 @@ class AudioOutputModule; } -class VoIPServerConfig : public Php::Base +class VoIPServerConfigInternal : public Php::Base { public: static void update(Php::Parameters ¶ms); - static Php::Value get(); - static void updateDefault(Php::Parameters ¶ms); - static Php::Value getDefault(); -private: - static Php::Array config; - static Php::Array configDefault; }; class VoIP : public Php::Base