@@ -21,9 +21,11 @@ constexpr char kEventChannelName[] = "tizen/internal/app_control_event";
2121AppControlChannel::AppControlChannel (BinaryMessenger* messenger) {
2222 method_channel_ = std::make_unique<MethodChannel<EncodableValue>>(
2323 messenger, kChannelName , &StandardMethodCodec::GetInstance ());
24- method_channel_->SetMethodCallHandler ([this ](const auto & call, auto result) {
25- this ->HandleMethodCall (call, std::move (result));
26- });
24+ method_channel_->SetMethodCallHandler (
25+ [this ](const MethodCall<EncodableValue>& call,
26+ std::unique_ptr<MethodResult<EncodableValue>> result) {
27+ this ->HandleMethodCall (call, std::move (result));
28+ });
2729
2830 event_channel_ = std::make_unique<EventChannel<EncodableValue>>(
2931 messenger, kEventChannelName , &StandardMethodCodec::GetInstance ());
@@ -65,21 +67,7 @@ void AppControlChannel::HandleMethodCall(
6567 std::unique_ptr<MethodResult<EncodableValue>> result) {
6668 const auto & method_name = method_call.method_name ();
6769
68- // The methods "create" and "dispose" are deprecated and will be removed in
69- // the future.
70- if (method_name == " create" ) {
71- auto app_control = std::make_unique<AppControl>();
72- if (app_control->handle ()) {
73- result->Success (EncodableValue (app_control->id ()));
74- AppControlManager::GetInstance ().Insert (std::move (app_control));
75- } else {
76- result->Error (" Internal error" ,
77- " Could not create an instance of AppControl." );
78- }
79- return ;
80- }
81-
82- auto arguments = std::get_if<EncodableMap>(method_call.arguments ());
70+ const auto * arguments = std::get_if<EncodableMap>(method_call.arguments ());
8371 if (!arguments) {
8472 result->Error (" Invalid arguments" );
8573 return ;
@@ -89,17 +77,14 @@ void AppControlChannel::HandleMethodCall(
8977 result->Error (" Invalid arguments" , " No ID provided." );
9078 return ;
9179 }
92- auto app_control = AppControlManager::GetInstance ().FindById (*id);
80+ AppControl* app_control = AppControlManager::GetInstance ().FindById (*id);
9381 if (!app_control) {
9482 result->Error (" Invalid arguments" ,
9583 " No instance of AppControl matches the given ID." );
9684 return ;
9785 }
9886
99- if (method_name == " dispose" ) {
100- AppControlManager::GetInstance ().Remove (app_control->id ());
101- result->Success ();
102- } else if (method_name == " getMatchedAppIds" ) {
87+ if (method_name == " getMatchedAppIds" ) {
10388 EncodableList app_ids;
10489 AppControlResult ret = app_control->GetMatchedAppIds (app_ids);
10590 if (ret) {
@@ -146,38 +131,18 @@ void AppControlChannel::Reply(
146131 }
147132
148133 EncodableValueHolder<int32_t > reply_id (arguments, " replyId" );
149- if (reply_id) {
150- auto reply_app_control =
151- AppControlManager::GetInstance ().FindById (*reply_id);
152- if (!reply_app_control) {
153- result->Error (" Invalid arguments" ,
154- " No instance of AppControl matches the given ID." );
155- return ;
156- }
157- AppControlResult ret = app_control->Reply (reply_app_control, *result_str);
158- if (ret) {
159- result->Success ();
160- } else {
161- result->Error (ret.code (), ret.message ());
162- }
163- return ;
164- }
165-
166- // Deprecated. Use replyId instead.
167- EncodableValueHolder<int32_t > request_id (arguments, " requestId" );
168- if (!request_id) {
169- result->Error (" Invalid arguments" ,
170- " Either replyId or requestId must be provided." );
134+ if (!reply_id) {
135+ result->Error (" Invalid arguments" , " No replyId provided." );
171136 return ;
172137 }
173- auto request_app_control =
174- AppControlManager::GetInstance ().FindById (*request_id );
175- if (!request_app_control ) {
138+ AppControl* reply_app_control =
139+ AppControlManager::GetInstance ().FindById (*reply_id );
140+ if (!reply_app_control ) {
176141 result->Error (" Invalid arguments" ,
177142 " No instance of AppControl matches the given ID." );
178143 return ;
179144 }
180- AppControlResult ret = request_app_control ->Reply (app_control , *result_str);
145+ AppControlResult ret = app_control ->Reply (reply_app_control , *result_str);
181146 if (ret) {
182147 result->Success ();
183148 } else {
@@ -191,7 +156,7 @@ void AppControlChannel::SendLaunchRequest(
191156 std::unique_ptr<MethodResult<EncodableValue>> result) {
192157 EncodableValueHolder<bool > wait_for_reply (arguments, " waitForReply" );
193158 if (wait_for_reply && *wait_for_reply) {
194- auto result_ptr = result.release ();
159+ auto * result_ptr = result.release ();
195160 auto on_reply = [result_ptr](const EncodableValue& response) {
196161 result_ptr->Success (response);
197162 delete result_ptr;
0 commit comments