From 2b6848be165f2b79c7e54373ec20de3dc35c87a0 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Fri, 22 Feb 2019 18:47:03 +0900 Subject: [PATCH 01/16] Fixed indent issue of the license phrase. Signed-off-by: saerome.kim --- include/ua-api.h | 7 +------ include/ua-internal.h | 6 +----- ua-api/include/ua-common.h | 6 +----- ua-api/include/ua-event-handler.h | 6 +----- ua-api/include/ua-request-sender.h | 6 +----- ua-api/src/ua-api.c | 7 +------ ua-api/src/ua-common.c | 6 +----- ua-api/src/ua-event-handler.c | 7 +------ ua-api/src/ua-request-sender.c | 6 +----- ua-daemon/include/ua-manager-common.h | 6 +----- ua-daemon/include/ua-manager-config-parser.h | 4 +--- ua-daemon/include/ua-manager-core.h | 6 +----- ua-daemon/include/ua-manager-database.h | 6 +----- ua-daemon/include/ua-plugin-manager.h | 6 +----- ua-daemon/include/ua-power-plugin-manager.h | 4 +--- ua-daemon/src/pm/ua-ble-plugin-handler.c | 6 +----- ua-daemon/src/pm/ua-light-plugin-handler.c | 6 +----- ua-daemon/src/pm/ua-motion-plugin-handler.c | 6 +----- ua-daemon/src/pm/ua-plugin-manager.c | 6 +----- ua-daemon/src/pm/ua-pm-util.c | 6 +----- ua-daemon/src/pm/ua-pm-util.h | 6 +----- ua-daemon/src/pm/ua-power-plugin-handler.c | 4 +--- ua-daemon/src/pm/ua-power-plugin-manager.c | 4 +--- ua-daemon/src/pm/ua-wifi-plugin-handler.c | 4 +--- ua-daemon/src/ua-manager-common.c | 6 +----- ua-daemon/src/ua-manager-config-parser.c | 4 +--- ua-daemon/src/ua-manager-core.c | 6 +----- ua-daemon/src/ua-manager-device-db.c | 6 +----- ua-daemon/src/ua-manager-event-sender.c | 6 +----- ua-daemon/src/ua-manager-main.c | 6 +----- ua-daemon/src/ua-manager-request-handler.c | 6 +----- ua-daemon/src/ua-manager-user-db.c | 6 +----- ua-plugins/include/ua-plugin.h | 6 +----- ua-plugins/include/ua-power-plugin.h | 6 +----- 34 files changed, 34 insertions(+), 161 deletions(-) mode change 100755 => 100644 ua-api/src/ua-request-sender.c diff --git a/include/ua-api.h b/include/ua-api.h index 2a0f1db..a7ae32d 100644 --- a/include/ua-api.h +++ b/include/ua-api.h @@ -1,16 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * Author: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/include/ua-internal.h b/include/ua-internal.h index eea2578..dfb3966 100644 --- a/include/ua-internal.h +++ b/include/ua-internal.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/include/ua-common.h b/ua-api/include/ua-common.h index a5224e4..3876b10 100644 --- a/ua-api/include/ua-common.h +++ b/ua-api/include/ua-common.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/include/ua-event-handler.h b/ua-api/include/ua-event-handler.h index 329a7ea..648e21d 100644 --- a/ua-api/include/ua-event-handler.h +++ b/ua-api/include/ua-event-handler.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/include/ua-request-sender.h b/ua-api/include/ua-request-sender.h index 9b8cf81..5d8f77b 100644 --- a/ua-api/include/ua-request-sender.h +++ b/ua-api/include/ua-request-sender.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/src/ua-api.c b/ua-api/src/ua-api.c index 74ddaf5..64f62f3 100644 --- a/ua-api/src/ua-api.c +++ b/ua-api/src/ua-api.c @@ -1,16 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * Author: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/src/ua-common.c b/ua-api/src/ua-common.c index b4b9327..65dd5be 100644 --- a/ua-api/src/ua-common.c +++ b/ua-api/src/ua-common.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/src/ua-event-handler.c b/ua-api/src/ua-event-handler.c index 4593c54..9a4af61 100644 --- a/ua-api/src/ua-event-handler.c +++ b/ua-api/src/ua-event-handler.c @@ -1,16 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * Author: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-api/src/ua-request-sender.c b/ua-api/src/ua-request-sender.c old mode 100755 new mode 100644 index 8d42040..cc4246a --- a/ua-api/src/ua-request-sender.c +++ b/ua-api/src/ua-request-sender.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-manager-common.h b/ua-daemon/include/ua-manager-common.h index d6145d2..0fb6922 100644 --- a/ua-daemon/include/ua-manager-common.h +++ b/ua-daemon/include/ua-manager-common.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-manager-config-parser.h b/ua-daemon/include/ua-manager-config-parser.h index e1ecf19..231c096 100644 --- a/ua-daemon/include/ua-manager-config-parser.h +++ b/ua-daemon/include/ua-manager-config-parser.h @@ -1,13 +1,11 @@ /* - * User Awareness Manager - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-manager-core.h b/ua-daemon/include/ua-manager-core.h index ee5b0e8..b1e168e 100644 --- a/ua-daemon/include/ua-manager-core.h +++ b/ua-daemon/include/ua-manager-core.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-manager-database.h b/ua-daemon/include/ua-manager-database.h index 7ebd25e..15ee05f 100644 --- a/ua-daemon/include/ua-manager-database.h +++ b/ua-daemon/include/ua-manager-database.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager Database API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Abhishek Sansanwal - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-plugin-manager.h b/ua-daemon/include/ua-plugin-manager.h index abfb742..7401dbd 100644 --- a/ua-daemon/include/ua-plugin-manager.h +++ b/ua-daemon/include/ua-plugin-manager.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/include/ua-power-plugin-manager.h b/ua-daemon/include/ua-power-plugin-manager.h index e0bd123..1e3586c 100644 --- a/ua-daemon/include/ua-power-plugin-manager.h +++ b/ua-daemon/include/ua-power-plugin-manager.h @@ -1,13 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-ble-plugin-handler.c b/ua-daemon/src/pm/ua-ble-plugin-handler.c index b36d434..d2ffcdb 100644 --- a/ua-daemon/src/pm/ua-ble-plugin-handler.c +++ b/ua-daemon/src/pm/ua-ble-plugin-handler.c @@ -1,15 +1,11 @@ /* - * User Awareness BLE plugin callback handler - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-light-plugin-handler.c b/ua-daemon/src/pm/ua-light-plugin-handler.c index 5cc4974..092f60d 100644 --- a/ua-daemon/src/pm/ua-light-plugin-handler.c +++ b/ua-daemon/src/pm/ua-light-plugin-handler.c @@ -1,15 +1,11 @@ /* - * User Awareness Light plugin callback handler - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-motion-plugin-handler.c b/ua-daemon/src/pm/ua-motion-plugin-handler.c index c2c36b7..1dff18a 100644 --- a/ua-daemon/src/pm/ua-motion-plugin-handler.c +++ b/ua-daemon/src/pm/ua-motion-plugin-handler.c @@ -1,15 +1,11 @@ /* - * User Awareness Light plugin callback handler - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-plugin-manager.c b/ua-daemon/src/pm/ua-plugin-manager.c index b2a17eb..42e371d 100644 --- a/ua-daemon/src/pm/ua-plugin-manager.c +++ b/ua-daemon/src/pm/ua-plugin-manager.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-pm-util.c b/ua-daemon/src/pm/ua-pm-util.c index f2840a7..58cf16e 100644 --- a/ua-daemon/src/pm/ua-pm-util.c +++ b/ua-daemon/src/pm/ua-pm-util.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-pm-util.h b/ua-daemon/src/pm/ua-pm-util.h index 3a76029..ec153df 100644 --- a/ua-daemon/src/pm/ua-pm-util.h +++ b/ua-daemon/src/pm/ua-pm-util.h @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-power-plugin-handler.c b/ua-daemon/src/pm/ua-power-plugin-handler.c index 822c26c..75c2d0b 100644 --- a/ua-daemon/src/pm/ua-power-plugin-handler.c +++ b/ua-daemon/src/pm/ua-power-plugin-handler.c @@ -1,13 +1,11 @@ /* - * User Awareness Power plugin callback handler - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-power-plugin-manager.c b/ua-daemon/src/pm/ua-power-plugin-manager.c index 2d48b07..d1fd091 100644 --- a/ua-daemon/src/pm/ua-power-plugin-manager.c +++ b/ua-daemon/src/pm/ua-power-plugin-manager.c @@ -1,13 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/pm/ua-wifi-plugin-handler.c b/ua-daemon/src/pm/ua-wifi-plugin-handler.c index 14f83e8..1f6da6c 100644 --- a/ua-daemon/src/pm/ua-wifi-plugin-handler.c +++ b/ua-daemon/src/pm/ua-wifi-plugin-handler.c @@ -1,13 +1,11 @@ /* - * User Awareness WIFI plugin callback handler - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-common.c b/ua-daemon/src/ua-manager-common.c index d76576a..ec9e9d2 100644 --- a/ua-daemon/src/ua-manager-common.c +++ b/ua-daemon/src/ua-manager-common.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-config-parser.c b/ua-daemon/src/ua-manager-config-parser.c index 456ed6d..63fbc7b 100644 --- a/ua-daemon/src/ua-manager-config-parser.c +++ b/ua-daemon/src/ua-manager-config-parser.c @@ -1,13 +1,11 @@ /* - * User Awareness Manager - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 1a32ba1..71f8ff4 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-device-db.c b/ua-daemon/src/ua-manager-device-db.c index de19ba5..241c9db 100644 --- a/ua-daemon/src/ua-manager-device-db.c +++ b/ua-daemon/src/ua-manager-device-db.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Abhishek Sansanwal - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-event-sender.c b/ua-daemon/src/ua-manager-event-sender.c index 6fff65b..13db7e3 100644 --- a/ua-daemon/src/ua-manager-event-sender.c +++ b/ua-daemon/src/ua-manager-event-sender.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-main.c b/ua-daemon/src/ua-manager-main.c index 6df08e9..8f509d8 100644 --- a/ua-daemon/src/ua-manager-main.c +++ b/ua-daemon/src/ua-manager-main.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-request-handler.c b/ua-daemon/src/ua-manager-request-handler.c index 32c8237..abf90b6 100644 --- a/ua-daemon/src/ua-manager-request-handler.c +++ b/ua-daemon/src/ua-manager-request-handler.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Atul Rai - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-daemon/src/ua-manager-user-db.c b/ua-daemon/src/ua-manager-user-db.c index 72e3506..2c4ee9d 100644 --- a/ua-daemon/src/ua-manager-user-db.c +++ b/ua-daemon/src/ua-manager-user-db.c @@ -1,15 +1,11 @@ /* - * User Awareness Manager Database API - * * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. * - * Author: Abhishek Sansanwal - * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-plugins/include/ua-plugin.h b/ua-plugins/include/ua-plugin.h index 7c171f0..eb87268 100644 --- a/ua-plugins/include/ua-plugin.h +++ b/ua-plugins/include/ua-plugin.h @@ -1,15 +1,11 @@ /* - * UA plugins interface - * * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved. * - * Contact: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/ua-plugins/include/ua-power-plugin.h b/ua-plugins/include/ua-power-plugin.h index 935b0e7..1fcd537 100644 --- a/ua-plugins/include/ua-power-plugin.h +++ b/ua-plugins/include/ua-power-plugin.h @@ -1,15 +1,11 @@ /* - * UA power plugins interface - * * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved. * - * Contact: Mayank Haarit - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, -- 2.7.4 From 6b0d6d34fc738f253c2fe533dfbbbf89eac74897 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Wed, 27 Feb 2019 18:17:03 +0900 Subject: [PATCH 02/16] Modified to terminate ua-manager when all clients are terminated. Signed-off-by: saerome.kim --- ua-daemon/src/ua-manager-main.c | 2 +- ua-daemon/src/ua-manager-request-handler.c | 93 ++++++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 13 deletions(-) diff --git a/ua-daemon/src/ua-manager-main.c b/ua-daemon/src/ua-manager-main.c index 8f509d8..3ac98a4 100644 --- a/ua-daemon/src/ua-manager-main.c +++ b/ua-daemon/src/ua-manager-main.c @@ -44,7 +44,7 @@ static void __uam_glib_log( static int __uam_manager_init(void) { FUNC_ENTRY; - int result; + int result = UAM_ERROR_NONE; result = _uam_manager_register(); retv_if(UAM_ERROR_NONE != result, result); diff --git a/ua-daemon/src/ua-manager-request-handler.c b/ua-daemon/src/ua-manager-request-handler.c index abf90b6..7d813a3 100644 --- a/ua-daemon/src/ua-manager-request-handler.c +++ b/ua-daemon/src/ua-manager-request-handler.c @@ -21,6 +21,14 @@ extern GMainLoop *main_loop; +/* global list to care resource handle for each client */ +static GSList *uam_dbus_clients; +static GMutex uam_dbus_clients_mutex; + +typedef struct _uam_dbus_client_s { + gchar *bus_name; +} uam_dbus_client_s; + /* For maintaining Application Sync API call requests */ GSList *request_list = NULL; @@ -568,6 +576,33 @@ static const GDBusInterfaceVTable uam_method_table = { {0} }; +static int __uam_comp_bus_name(const void *a, const void *b) +{ + const uam_dbus_client_s *client = a; + + retv_if(NULL == a || NULL == b, -1); + + return g_strcmp0(client->bus_name, b); +} + +static inline GSList* __uam_list_find_client(const gchar *owner) +{ + return g_slist_find_custom(uam_dbus_clients, owner, + __uam_comp_bus_name); +} + +static void __uamd_dbus_client_cleanup(gpointer data) +{ + uam_dbus_client_s *client = data; + + ret_if(NULL == data); + + g_free(client->bus_name); + client->bus_name = NULL; + g_free(client); + client = NULL; +} + static void __uam_enabler_method( GDBusConnection *connection, const gchar *sender, @@ -581,21 +616,43 @@ static void __uam_enabler_method( FUNC_ENTRY; int enable = FALSE; int result = UAM_ERROR_NONE; + GSList *list = NULL; - UAM_DBG("Method[%s] Path[%s] Interface[%s]", - method_name, object_path, interface_name); + UAM_DBG("Sender[%s] Method[%s] Path[%s] Interface[%s]", + sender, method_name, object_path, interface_name); if (0 == g_strcmp0(method_name, "enable")) { g_variant_get(parameters, "(i)", &enable); if (TRUE == enable) { - /* To-Do : We should add user to list - * and Enabler ua-manager */ + UAM_DBG("Enable ua-manager"); + + list = __uam_list_find_client(sender); + if (NULL == list) { + uam_dbus_client_s *client = g_malloc(sizeof(uam_dbus_client_s)); + if (NULL == client) { + UAM_ERR("Faild to allocate memory"); + /* To-Do clearn up */ + return; + } + + client->bus_name = g_strdup(sender); + + g_mutex_lock(&uam_dbus_clients_mutex); + uam_dbus_clients = g_slist_prepend(uam_dbus_clients, client); + g_mutex_unlock(&uam_dbus_clients_mutex); + } } else { - /* To-Do : If only one user is activated, - * we should terminite daemon */ UAM_DBG("Disable ua-manager"); - g_main_loop_quit(main_loop); + + g_mutex_lock(&uam_dbus_clients_mutex); + list = __uam_list_find_client(sender); + if (list) { + /* found bus name in our bus list */ + __uamd_dbus_client_cleanup((gpointer)list->data); + uam_dbus_clients = g_slist_remove_link(uam_dbus_clients, list); + } + g_mutex_unlock(&uam_dbus_clients_mutex); } g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", result)); @@ -725,17 +782,29 @@ static void __uam_manager_name_owner_changed_cb(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { + int count = 0; const char *name = NULL; const char *old_owner = NULL; const char *new_owner = NULL; g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner); - if (*new_owner != '\0') - return; - /* Cleanup all pending request from this sender */ - __uam_manager_cleanup_requests_from_sender(name); -} + UAM_ERR("old_owner[%s] new_owner[%s] size[%d]", + old_owner, new_owner, g_slist_length(uam_dbus_clients)); + + if ('\0' == *new_owner) { + g_mutex_lock(&uam_dbus_clients_mutex); + count = g_slist_length(uam_dbus_clients); + g_mutex_unlock(&uam_dbus_clients_mutex); + if (0 == count) { + /* Cleanup all pending request from this sender */ + __uam_manager_cleanup_requests_from_sender(name); + + UAM_ERR("Quit ua-manager"); + g_main_loop_quit(main_loop); + } + + }} static void __uam_manager_name_acquired_cb( GDBusConnection *connection, const gchar *name, gpointer user_data) -- 2.7.4 From 227cb9a687c69198a727c09bcaeecf94208b9fa6 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Thu, 28 Feb 2019 13:38:37 +0900 Subject: [PATCH 03/16] Deleted unnecessary log. Signed-off-by: saerome.kim --- ua-daemon/src/ua-manager-request-handler.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ua-daemon/src/ua-manager-request-handler.c b/ua-daemon/src/ua-manager-request-handler.c index 7d813a3..252248c 100644 --- a/ua-daemon/src/ua-manager-request-handler.c +++ b/ua-daemon/src/ua-manager-request-handler.c @@ -789,9 +789,6 @@ static void __uam_manager_name_owner_changed_cb(GDBusConnection *connection, g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner); - UAM_ERR("old_owner[%s] new_owner[%s] size[%d]", - old_owner, new_owner, g_slist_length(uam_dbus_clients)); - if ('\0' == *new_owner) { g_mutex_lock(&uam_dbus_clients_mutex); count = g_slist_length(uam_dbus_clients); -- 2.7.4 From fd1b7c5db25116b022c8be2882f6446b2bc9b038 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Wed, 6 Mar 2019 11:23:47 +0530 Subject: [PATCH 04/16] Invoke UAM_REQUEST_ADD_DEVICE as ASYNC API Signed-off-by: Atul Rai --- ua-api/src/ua-api.c | 4 ++-- ua-api/src/ua-request-sender.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ua-api/src/ua-api.c b/ua-api/src/ua-api.c index 64f62f3..ea21c06 100644 --- a/ua-api/src/ua-api.c +++ b/ua-api/src/ua-api.c @@ -341,8 +341,8 @@ UAM_EXPORT_API int _uam_request_add_device(char* account, uam_device_info_t* dev g_strlcpy(str, account, UAM_USER_ACCOUNT_MAX_STRING_LEN); g_array_append_vals(in_param1, str, sizeof(str)); g_array_append_vals(in_param2, device, sizeof(uam_device_info_t)); - ret = _uam_sync_request(UAM_REQUEST_ADD_DEVICE, - in_param1, in_param2, in_param3, in_param4, &out_param); + ret = _uam_async_request(UAM_REQUEST_ADD_DEVICE, in_param1, in_param2, + in_param3, in_param4, cb_info.callback, cb_info.user_data); UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); diff --git a/ua-api/src/ua-request-sender.c b/ua-api/src/ua-request-sender.c index cc4246a..940c1a8 100644 --- a/ua-api/src/ua-request-sender.c +++ b/ua-api/src/ua-request-sender.c @@ -88,6 +88,12 @@ static void __uam_get_event_info(int req_func, GArray *output, _uam_request_to_str(req_func), req_func); switch (req_func) { + case UAM_REQUEST_ADD_DEVICE: + *event = UAM_EVENT_DEVICE_ADDED; + ret_if(output == NULL); + *param_data = &g_array_index(output, + uam_device_info_t, 0); + break; default: UAM_ERR("Unknown request function"); return; -- 2.7.4 From 5c2a92c81027c3914b4d796363bee6bb9d1c011b Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Fri, 8 Mar 2019 16:21:03 +0900 Subject: [PATCH 05/16] Fix circleci configuration It will use specific version of gbs. Change-Id: I54d747dc92910b9717a1a0d7571b2800e452bc41 Signed-off-by: Semun Lee --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d627e1e..059c76a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: - run: name: Install gbs command: | - echo "deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_16.04/ /" | sudo tee /etc/apt/sources.list.d/tizen.list + echo "deb [trusted=yes] http://download.tizen.org/tools/archive/19.03/Ubuntu_16.04/ /" | sudo tee /etc/apt/sources.list.d/tizen.list sudo apt-get update sudo apt-get install -y gbs find /proc/sys/fs/binfmt_misc/ -not -name status -not -name register -type f -exec sh -c "echo -1 | sudo tee {}" \; -- 2.7.4 From 755bc207b99b78509d0cd64a61d7f8f7e593fda6 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 11 Mar 2019 17:28:34 +0900 Subject: [PATCH 06/16] Fixed build error due to dbus-policy checker - how to test : dbus-policychecker /etc/dbus-1/system.d/net.uamd.conf Signed-off-by: saerome.kim --- packaging/ua-manager.conf | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packaging/ua-manager.conf b/packaging/ua-manager.conf index 5dea756..0cde71b 100644 --- a/packaging/ua-manager.conf +++ b/packaging/ua-manager.conf @@ -3,23 +3,23 @@ - - - - - + + + + - - - - - + + + + + + + + + + + - - - - - -- 2.7.4 From 0c44678aa6759b2ddcccff1456488b8c4f8d2762 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Mon, 11 Mar 2019 16:21:21 +0530 Subject: [PATCH 07/16] Fixed ua-client cleanup on app termination Signed-off-by: Atul Rai --- ua-api/src/ua-api.c | 1 + ua-daemon/src/ua-manager-request-handler.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ua-api/src/ua-api.c b/ua-api/src/ua-api.c index ea21c06..d24fa07 100644 --- a/ua-api/src/ua-api.c +++ b/ua-api/src/ua-api.c @@ -35,6 +35,7 @@ UAM_EXPORT_API int _uam_init(uam_event_callback cb, void *user_data) ret = _uam_sync_enable(TRUE); if (UAM_ERROR_NONE != ret) { + UAM_ERR("_uam_sync_enable(TRUE) failed"); return ret; } diff --git a/ua-daemon/src/ua-manager-request-handler.c b/ua-daemon/src/ua-manager-request-handler.c index 252248c..f7e1860 100644 --- a/ua-daemon/src/ua-manager-request-handler.c +++ b/ua-daemon/src/ua-manager-request-handler.c @@ -751,7 +751,6 @@ static int __uam_manager_unregister_object(GDBusConnection *conn) static void __uam_manager_cleanup_requests_from_sender(const char *name) { -// FUNC_ENTRY; GSList *l; ret_if(NULL == name); @@ -771,7 +770,6 @@ static void __uam_manager_cleanup_requests_from_sender(const char *name) /* App terminated, cleanup monitor list */ _uam_core_cleanup_monitor((char *)name); -// FUNC_EXIT; } static void __uam_manager_name_owner_changed_cb(GDBusConnection *connection, @@ -782,26 +780,34 @@ static void __uam_manager_name_owner_changed_cb(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { - int count = 0; + int count = 1; const char *name = NULL; const char *old_owner = NULL; const char *new_owner = NULL; + GSList *list; g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner); if ('\0' == *new_owner) { + /* Cleanup all pending request from this sender */ + __uam_manager_cleanup_requests_from_sender(name); + g_mutex_lock(&uam_dbus_clients_mutex); - count = g_slist_length(uam_dbus_clients); + list = __uam_list_find_client(name); + if (list) { + /* found bus name in our bus list */ + __uamd_dbus_client_cleanup((gpointer)list->data); + uam_dbus_clients = g_slist_remove_link(uam_dbus_clients, list); + count = g_slist_length(uam_dbus_clients); + } g_mutex_unlock(&uam_dbus_clients_mutex); - if (0 == count) { - /* Cleanup all pending request from this sender */ - __uam_manager_cleanup_requests_from_sender(name); + if (0 == count) { UAM_ERR("Quit ua-manager"); g_main_loop_quit(main_loop); } - - }} + } +} static void __uam_manager_name_acquired_cb( GDBusConnection *connection, const gchar *name, gpointer user_data) -- 2.7.4 From 40a9f7b56862b53ff3abcedf2e0f917d4110cc00 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Tue, 12 Mar 2019 17:10:40 +0530 Subject: [PATCH 08/16] Add app to monitor list if detection is already started Signed-off-by: Atul Rai --- ua-daemon/src/ua-manager-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 71f8ff4..b11d14f 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -1250,9 +1250,8 @@ static int __uam_core_start_detection(int detection_type, char *sender, unsigned return ret; } - monitors = g_slist_append(monitors, monitor); - done: + monitors = g_slist_append(monitors, monitor); monitor->sensors |= sensors; FUNC_EXIT; -- 2.7.4 From 973944da740a91ca2b6642c1ec9b6df36f7d186c Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Thu, 14 Mar 2019 10:33:07 +0530 Subject: [PATCH 09/16] Added Cloud plugin handler in ua-manager Signed-off-by: Atul Rai --- ua-daemon/CMakeLists.txt | 1 + ua-daemon/include/ua-cloud-plugin-handler.h | 33 ++++ ua-daemon/include/ua-manager-common.h | 9 + ua-daemon/include/ua-plugin-manager.h | 8 - ua-daemon/src/pm/ua-cloud-plugin-handler.c | 263 ++++++++++++++++++++++++++++ ua-daemon/src/ua-manager-core.c | 40 ++++- ua-plugins/include/ua-cloud-plugin.h | 172 ++++++++++++++++++ 7 files changed, 515 insertions(+), 11 deletions(-) create mode 100644 ua-daemon/include/ua-cloud-plugin-handler.h create mode 100644 ua-daemon/src/pm/ua-cloud-plugin-handler.c create mode 100644 ua-plugins/include/ua-cloud-plugin.h diff --git a/ua-daemon/CMakeLists.txt b/ua-daemon/CMakeLists.txt index b9f2128..7142fcf 100644 --- a/ua-daemon/CMakeLists.txt +++ b/ua-daemon/CMakeLists.txt @@ -24,6 +24,7 @@ SET(SRCS IF("$ENV{CFLAGS}" MATCHES "-DVD_REQ") LIST(APPEND SRCS src/pm/ua-power-plugin-manager.c) LIST(APPEND SRCS src/pm/ua-power-plugin-handler.c) + LIST(APPEND SRCS src/pm/ua-cloud-plugin-handler.c) ENDIF() IF("${CMAKE_BUILD_TYPE}" STREQUAL "") diff --git a/ua-daemon/include/ua-cloud-plugin-handler.h b/ua-daemon/include/ua-cloud-plugin-handler.h new file mode 100644 index 0000000..76e5ffd --- /dev/null +++ b/ua-daemon/include/ua-cloud-plugin-handler.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __UAM_CLOUD_PLUGIN_HANDLER_H__ +#define __UAM_CLOUD_PLUGIN_HANDLER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void _uam_cloud_set_registered_devices(GSList *devices); + +void _uam_cloud_send_device_added(int status, int user_id, + const uam_device_info_t *dev_info); + +#ifdef __cplusplus +} +#endif +#endif /* __UAM_CLOUD_PLUGIN_HANDLER_H__ */ diff --git a/ua-daemon/include/ua-manager-common.h b/ua-daemon/include/ua-manager-common.h index 0fb6922..faf9394 100644 --- a/ua-daemon/include/ua-manager-common.h +++ b/ua-daemon/include/ua-manager-common.h @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -53,6 +54,14 @@ extern "C" { #define FUNC_ENTRY UAM_DBG("+") #define FUNC_EXIT UAM_DBG("-") +#define PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib") +#ifdef VD_REQ +#define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power") +#define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud") +#endif + +#define UAM_VERSION "0.1" + #define ret_if(expr) \ do { \ if (expr) { \ diff --git a/ua-daemon/include/ua-plugin-manager.h b/ua-daemon/include/ua-plugin-manager.h index 7401dbd..e66eeb0 100644 --- a/ua-daemon/include/ua-plugin-manager.h +++ b/ua-daemon/include/ua-plugin-manager.h @@ -27,14 +27,6 @@ extern "C" { #endif -#define PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib") -#define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power") - -#define UAM_VERSION "0.1" - -//#define PATH_MAX 4096 + 1 /**< Max. linux path length */ -//#define NAME_MAX 255 + 1 /**< Max. linux file name length */ - typedef enum { UAM_DETECT_PRESENCE = 0x01, UAM_DETECT_ABSENCE = 0x02, diff --git a/ua-daemon/src/pm/ua-cloud-plugin-handler.c b/ua-daemon/src/pm/ua-cloud-plugin-handler.c new file mode 100644 index 0000000..9042236 --- /dev/null +++ b/ua-daemon/src/pm/ua-cloud-plugin-handler.c @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +typedef struct { + void *handle; + void *module; + void *api; +} uam_plugin_info_t; + +uam_plugin_info_t *cloud_plugin; + +static int add_user(const char *account, const char *name) +{ + FUNC_ENTRY; + + FUNC_EXIT; + return UAC_STATUS_SUCCESS; +} + +static int remove_user(const char *account) +{ + FUNC_ENTRY; + + FUNC_EXIT; + return UAC_STATUS_SUCCESS; +} + +static int add_device(const char *account, uac_device_info_t *dev_info) +{ + FUNC_ENTRY; + + FUNC_EXIT; + return UAC_STATUS_SUCCESS; +} + +static int remove_device(const char *account, char* device_id) +{ + FUNC_ENTRY; + + FUNC_EXIT; + return UAC_STATUS_SUCCESS; +} + +static void reset_ua_db(void) +{ + FUNC_ENTRY; + + FUNC_EXIT; +} + +uac_callbacks_t cloud_cb = { + .add_user_cb = add_user, + .remove_user_cb = remove_user, + .add_device_cb = add_device, + .remove_device_cb = remove_device, + .reset_cb = reset_ua_db +}; + +void _uam_cloud_set_registered_devices(GSList *devices) +{ + FUNC_ENTRY; + + FUNC_EXIT; +} + +void _uam_cloud_send_device_added(int status, int user_id, + const uam_device_info_t *dev_info) +{ + FUNC_ENTRY; + + FUNC_EXIT; +} + +static gboolean __add_cloud_plugin(void *handle, uac_module_t *module) +{ + FUNC_ENTRY; + uac_api_t *api = NULL; + uam_plugin_info_t *plugin; + + UAM_DBG("Plugin [id: %d, name: %s, version: %s]", + module->id, module->name, module->version); + + if (PLUGIN_ID_CLOUD != module->id) { + UAM_ERR("Unknown Id %d for %s", module->id, module->name); + return FALSE; + } + + if (NULL != cloud_plugin) { + UAM_ERR("Plugin %s already added", + ((uac_module_t *)cloud_plugin->module)->name); + return FALSE; + } + + if (g_str_equal(module->version, UAM_VERSION) == FALSE) { + UAM_ERR("Version (%s) mismatch for %s", + module->version, module->name); + return FALSE; + } + + plugin = g_try_new0(uam_plugin_info_t, 1); + if (NULL == plugin) { + UAM_ERR("Memory allocation failed"); + return FALSE; + } + + retv_if(NULL == module->init, FALSE); + + module->init(&api); + if (NULL == api) { + UAM_ERR("API returned is NULL"); + return FALSE; + } + + plugin->handle = handle; + plugin->module = module; + plugin->api = api; + + cloud_plugin = plugin; + + FUNC_EXIT; + return TRUE; +} + +static int __load_cloud_plugin(void) +{ + FUNC_ENTRY; + GDir *dir; + const char *name; + int ret = UAM_ERROR_INTERNAL; + + retv_if(0 == strlen(CLOUD_PLUGIN_DIR), UAM_ERROR_INTERNAL); + UAM_DBG("Loading plugins from %s", CLOUD_PLUGIN_DIR); + + dir = g_dir_open(CLOUD_PLUGIN_DIR, 0, NULL); + if (!dir) { + UAM_ERR("Unable to open directory %s", CLOUD_PLUGIN_DIR); + return UAM_ERROR_INTERNAL; + } + + while ((name = g_dir_read_name(dir)) != NULL) { + char *filename; + void *handle; + uac_module_t *module; + + if (g_str_has_suffix(name, ".so") == FALSE) + continue; + + filename = g_build_filename(CLOUD_PLUGIN_DIR, name, NULL); + UAM_DBG("Loading [%s]", filename); + + handle = dlopen(filename, RTLD_NOW); + g_free(filename); + if (handle == NULL) { + UAM_ERR("Can't load plugin %s", dlerror()); + continue; + } + + module = (uac_module_t *)dlsym(handle, "uac_module"); + if (module == NULL) { + UAM_ERR("Can't load plugin module: %s", dlerror()); + dlclose(handle); + continue; + } + + if (FALSE == __add_cloud_plugin(handle, module)) { + UAM_WARN("__add_cloud_plugin failed"); + continue; + } + + ret = UAM_ERROR_NONE; + break; + } + + g_dir_close(dir); + FUNC_EXIT; + return ret; +} + +static void __deinit_cloud_plugin(void) +{ + FUNC_ENTRY; + uac_api_t *api = (uac_api_t *)cloud_plugin->api; + uac_module_t *module = (uac_module_t *)cloud_plugin->module; + + /* Deinitialize and unload cloud plugins */ + ret_if(NULL == cloud_plugin); + + if (api && api->deinit) + api->deinit(); + + if (module && module->deinit) + module->deinit(); + + if (cloud_plugin->handle) + dlclose(cloud_plugin->handle); + + g_free(cloud_plugin); + cloud_plugin = NULL; + FUNC_EXIT; +} + +static int __init_cloud_plugin(void) +{ + FUNC_ENTRY; + int status; + + /* Initialize loaded power plugins */ + retv_if(UAM_ERROR_NONE != __load_cloud_plugin(), UAM_ERROR_INTERNAL); + + if (!cloud_plugin || !cloud_plugin->api) { + UAM_WARN("Cloud plugin is NULL"); + return UAM_ERROR_NOT_IN_OPERATION; + } + + status = ((uac_api_t *)cloud_plugin->api)->init(&cloud_cb); + if (UAC_STATUS_SUCCESS != status) { + /* Deinit plugin */ + __deinit_cloud_plugin(); + return UAM_ERROR_INTERNAL; + } + + FUNC_EXIT; + return UAM_ERROR_NONE; +} + +static void __attribute__((constructor)) _uam_cloud_init(void) +{ + FUNC_ENTRY; + int ret; + + ret = __init_cloud_plugin(); + ret_if(UAM_ERROR_NONE != ret); + UAM_INFO_C("__init_cloud_plugin done"); + + FUNC_EXIT; +} + +static void __attribute__((destructor)) _uam_cloud_deinit(void) +{ + FUNC_ENTRY; + __deinit_cloud_plugin(); + FUNC_EXIT; +} diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index b11d14f..64c8783 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -27,6 +27,7 @@ #ifdef VD_REQ #include "ua-power-plugin-manager.h" +#include "ua-cloud-plugin-handler.h" #endif #define UAM_MAX_USERS 255 @@ -239,6 +240,10 @@ static void __free_uam_db_user_info(gpointer data) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif __uam_core_release_user_id(user->user_id); g_free(user->name); g_free(user->account); @@ -810,6 +815,10 @@ int _uam_core_remove_device(const char *account, const uam_device_info_t *dev_in if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif FUNC_EXIT; return UAM_ERROR_NONE; } @@ -878,6 +887,10 @@ int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif FUNC_EXIT; return UAM_ERROR_NONE; } @@ -936,6 +949,10 @@ int _uam_core_remove_device_by_mac(const char *mac) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif FUNC_EXIT; return UAM_ERROR_NONE; } @@ -1467,6 +1484,10 @@ int _uam_core_init(void) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif FUNC_EXIT; return UAM_ERROR_NONE; } @@ -1576,12 +1597,13 @@ void _uam_core_handle_device_added(int status, } } l = g_slist_find_custom(users, USER_ACCOUNT_DEFAULT, __compare_user_account); - if (l) - user = l->data; - else { + if (!l) { UAM_ERR("_uam_core_add_user failed because user is null"); return; } + + user = l->data; + user_id = user->user_id; } else { l = g_slist_find_custom(users, &user_id, __compare_user_id); if (NULL == l) { @@ -1608,6 +1630,14 @@ void _uam_core_handle_device_added(int status, UAM_ERR("_uam_pm_set_registered_devices failed"); } +#ifdef VD_REQ + _uam_cloud_send_device_added(status, user_id, dev_info); + + /* Set/update registered device list to cloud plugin */ + if (UAM_ERROR_NONE == status) + _uam_cloud_set_registered_devices(devices); +#endif + FUNC_EXIT; } @@ -1877,5 +1907,9 @@ void _uam_core_reset_database(void) UAM_ERR("_uam_pm_set_registered_devices failed with %s", _uam_manager_error_to_str(ret)); +#ifdef VD_REQ + /* Set/update registered device list to cloud plugin */ + _uam_cloud_set_registered_devices(devices); +#endif FUNC_EXIT; } diff --git a/ua-plugins/include/ua-cloud-plugin.h b/ua-plugins/include/ua-cloud-plugin.h new file mode 100644 index 0000000..c905229 --- /dev/null +++ b/ua-plugins/include/ua-cloud-plugin.h @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __UAM_CLOUD_PLUGIN_H__ +#define __UAM_CLOUD_PLUGIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define PLUGIN_ID_CLOUD 0x21 + +/* UA power plugin return status */ +typedef enum { + UAC_STATUS_SUCCESS = 0x00, + UAC_STATUS_FAIL = 0x01, + UAC_STATUS_NOT_READY = 0x02, + UAC_STATUS_NOMEM = 0x03, + UAC_STATUS_BUSY = 0x04, + UAC_STATUS_ALREADY_DONE = 0x05, + UAC_STATUS_UNSUPPORTED = 0x06, + UAC_STATUS_TIMEOUT = 0x07, + UAC_STATUS_INVALID_PARAMS = 0x08, +} uac_status_e; + +/* Device Address types */ +typedef enum { + UAC_ADDR_TYPE_BT = 0x01, + UAC_ADDR_TYPE_BLE, + UAC_ADDR_TYPE_WIFI, + UAC_ADDR_TYPE_P2P, + UAC_ADDR_TYPE_IPv4, + UAC_ADDR_TYPE_IPv6, + UAC_ADDR_TYPE_INVALID +} uac_address_type_e; + +/* Device address information structure */ +typedef struct { + uac_address_type_e type; + char *address; +} uac_address_info_t; + +/* Device information structure */ +typedef struct { + int user_id; + unsigned int supported_techs; + char *device_id; + int os; + int num_addr; + uac_address_info_t *addr_list; +} uac_device_info_t; + +/* + * DIRECTION: Cloud-plugin ---> ua-manager + * This callback will be invoked to request user addition in ua database. + * [Param] account - User account id + * [Param] name - User name + */ +typedef int (*add_user_callback)(const char *account, const char *name); + +/* + * DIRECTION: Cloud-plugin ---> ua-manager + * This callback will be invoked to request user deletion from ua database. + * [Param] account - User account id + */ +typedef int (*remove_user_callback)(const char *account); + +/* + * DIRECTION: Cloud-plugin ---> ua-manager + * This callback will be invoked to request device addition in ua database. + * [Param] account - Device's user account id + * [Param] dev_info - Device information + */ +typedef int (*add_device_callback)(const char *account, uac_device_info_t *dev_info); + +/* + * DIRECTION: Cloud-plugin ---> ua-manager + * This callback will be invoked to request device deletion from ua database. + * [Param] account - Device's user account id + * [Param] device_id - Unique device Id + */ +typedef int (*remove_device_callback)(const char *account, char* device_id); + +/* + * DIRECTION: Cloud-plugin ---> ua-manager + * This callback will be invoked to request ua database reset. + */ +typedef void (*reset_ua_db_callback)(void); + +/* Cloud plug-in callback structure */ +typedef struct { + add_user_callback add_user_cb; + remove_user_callback remove_user_cb; + add_device_callback add_device_cb; + remove_device_callback remove_device_cb; + reset_ua_db_callback reset_cb; +} uac_callbacks_t; + +typedef struct { + /* + * DIRECTION: ua-manager ---> Cloud-plugin + * [Sync API] To initialize cloud plug-in + * [Param] callbacks - Callback structre + */ + int (*init)(uac_callbacks_t *callbacks); + + /* + * DIRECTION: ua-manager ---> Cloud-plugin + * [Sync API] To de-initialize cloud plug-in + */ + int (*deinit)(void); + + /* + * DIRECTION: ua-manager ---> Cloud-plugin + * [Sync API] To send registered device list from ua db to plug-in. + * This api will be invoked whenever device list changes (On device addition/removal). + * [Param] num_devices - Number of registered devices. + * [Param] devices - List of registered devices. + */ + int (*set_registered_devices)(int num_devices, uac_device_info_t *devices); + + /* + * DIRECTION: ua-manager ---> Cloud-plugin + * This API is invoked whenever a device is added in ua db. + * It is also used to send response for add_device_callback(). + * [Param] status - status for device add request + * [Param] dev_info - Device info for added device + */ + int (*device_added)(int status, uac_device_info_t *dev_info); +} uac_api_t; + +typedef struct { + /** Identifier of module */ + int id; + + /** Name of this module */ + const char *name; + + /** Author/owner/implementor of the module */ + const char *author; + + /** Version of the module-specific plugin API */ + const char *version; + + /** Modules init */ + int (*init)(uac_api_t **api); + + /** Modules de-init */ + int (*deinit)(void); +} uac_module_t; + +#define UAC_MODULE_ADD(name, author, version, init, deinit) \ + uac_module_t uac_module = { PLUGIN_ID_CLOUD, name, author, version, init, deinit }; + +#ifdef __cplusplus +} +#endif +#endif /* __UAM_CLOUD_PLUGIN_H__ */ -- 2.7.4 From deab27bdc8de74013a8dc27c07da077978955285 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Thu, 14 Mar 2019 10:39:24 +0530 Subject: [PATCH 10/16] Fixed Tizen coding rule errors Signed-off-by: Atul Rai --- include/ua-api.h | 2 +- ua-api/src/ua-api.c | 3 +-- ua-daemon/include/ua-cloud-plugin-handler.h | 2 +- ua-plugins/include/ua-cloud-plugin.h | 12 ++++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/ua-api.h b/include/ua-api.h index a7ae32d..9621b8e 100644 --- a/include/ua-api.h +++ b/include/ua-api.h @@ -68,7 +68,7 @@ typedef enum { #define FOREACH_ERROR(ERROR) \ ERROR(UAM_ERROR_NONE, TIZEN_ERROR_NONE) \ ERROR(UAM_ERROR_INVALID_PARAM, TIZEN_ERROR_INVALID_PARAMETER) \ - ERROR(UAM_ERROR_PERMISSION_DENIED,TIZEN_ERROR_PERMISSION_DENIED) \ + ERROR(UAM_ERROR_PERMISSION_DENIED, TIZEN_ERROR_PERMISSION_DENIED) \ ERROR(UAM_ERROR_TIMEOUT, TIZEN_ERROR_TIMED_OUT) \ ERROR(UAM_ERROR_NOW_IN_PROGRESS, TIZEN_ERROR_NOW_IN_PROGRESS) \ ERROR(UAM_ERROR_NOT_SUPPORTED, TIZEN_ERROR_NOT_SUPPORTED) \ diff --git a/ua-api/src/ua-api.c b/ua-api/src/ua-api.c index d24fa07..1f71b25 100644 --- a/ua-api/src/ua-api.c +++ b/ua-api/src/ua-api.c @@ -55,9 +55,8 @@ UAM_EXPORT_API int _uam_deinit(void) int ret; ret = _uam_sync_enable(FALSE); - if (UAM_ERROR_NONE != ret) { + if (UAM_ERROR_NONE != ret) return ret; - } ret = _uam_unregister_event_handler(); diff --git a/ua-daemon/include/ua-cloud-plugin-handler.h b/ua-daemon/include/ua-cloud-plugin-handler.h index 76e5ffd..0577963 100644 --- a/ua-daemon/include/ua-cloud-plugin-handler.h +++ b/ua-daemon/include/ua-cloud-plugin-handler.h @@ -25,7 +25,7 @@ extern "C" { void _uam_cloud_set_registered_devices(GSList *devices); void _uam_cloud_send_device_added(int status, int user_id, - const uam_device_info_t *dev_info); + const uam_device_info_t *dev_info); #ifdef __cplusplus } diff --git a/ua-plugins/include/ua-cloud-plugin.h b/ua-plugins/include/ua-cloud-plugin.h index c905229..df1281e 100644 --- a/ua-plugins/include/ua-cloud-plugin.h +++ b/ua-plugins/include/ua-cloud-plugin.h @@ -124,13 +124,13 @@ typedef struct { */ int (*deinit)(void); - /* + /* * DIRECTION: ua-manager ---> Cloud-plugin - * [Sync API] To send registered device list from ua db to plug-in. - * This api will be invoked whenever device list changes (On device addition/removal). - * [Param] num_devices - Number of registered devices. - * [Param] devices - List of registered devices. - */ + * [Sync API] To send registered device list from ua db to plug-in. + * This api will be invoked whenever device list changes (On device addition/removal). + * [Param] num_devices - Number of registered devices. + * [Param] devices - List of registered devices. + */ int (*set_registered_devices)(int num_devices, uac_device_info_t *devices); /* -- 2.7.4 From e057f4c8855f6b01004f2385f26ff7a2892675eb Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Thu, 14 Mar 2019 11:31:45 +0530 Subject: [PATCH 11/16] [Fix review comments] Modify plugin directory path Signed-off-by: Atul Rai --- ua-daemon/include/ua-manager-common.h | 2 +- ua-daemon/src/pm/ua-plugin-manager.c | 8 ++++---- ua-daemon/src/ua-manager-core.c | 22 +++++++--------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ua-daemon/include/ua-manager-common.h b/ua-daemon/include/ua-manager-common.h index faf9394..b838e96 100644 --- a/ua-daemon/include/ua-manager-common.h +++ b/ua-daemon/include/ua-manager-common.h @@ -54,7 +54,7 @@ extern "C" { #define FUNC_ENTRY UAM_DBG("+") #define FUNC_EXIT UAM_DBG("-") -#define PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib") +#define SENSOR_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/sensor") #ifdef VD_REQ #define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power") #define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud") diff --git a/ua-daemon/src/pm/ua-plugin-manager.c b/ua-daemon/src/pm/ua-plugin-manager.c index 42e371d..3a13745 100644 --- a/ua-daemon/src/pm/ua-plugin-manager.c +++ b/ua-daemon/src/pm/ua-plugin-manager.c @@ -136,11 +136,11 @@ static int __load_sensor_plugins(void) const char *filename; int ret = UAM_ERROR_INTERNAL; - retv_if(0 == strlen(PLUGIN_DIR), UAM_ERROR_INVALID_PARAM); + retv_if(0 == strlen(SENSOR_PLUGIN_DIR), UAM_ERROR_INVALID_PARAM); - UAM_DBG("Loading plugins from %s", PLUGIN_DIR); + UAM_DBG("Loading plugins from %s", SENSOR_PLUGIN_DIR); - dir = g_dir_open(PLUGIN_DIR, 0, NULL); + dir = g_dir_open(SENSOR_PLUGIN_DIR, 0, NULL); if (!dir) { UAM_ERR("Unable to open directory"); return UAM_ERROR_INTERNAL; @@ -153,7 +153,7 @@ static int __load_sensor_plugins(void) /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */ if (UAM_ERROR_NONE == __load_plugin( - PLUGIN_DIR, filename, "uas_module")) + SENSOR_PLUGIN_DIR, filename, "uas_module")) ret = UAM_ERROR_NONE; } diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 64c8783..ae5d0fe 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -24,10 +24,10 @@ #include "ua-manager-database.h" #include "ua-manager-config-parser.h" +#include "ua-cloud-plugin-handler.h" #ifdef VD_REQ #include "ua-power-plugin-manager.h" -#include "ua-cloud-plugin-handler.h" #endif #define UAM_MAX_USERS 255 @@ -240,10 +240,9 @@ static void __free_uam_db_user_info(gpointer data) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + __uam_core_release_user_id(user->user_id); g_free(user->name); g_free(user->account); @@ -815,10 +814,9 @@ int _uam_core_remove_device(const char *account, const uam_device_info_t *dev_in if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + FUNC_EXIT; return UAM_ERROR_NONE; } @@ -887,10 +885,9 @@ int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + FUNC_EXIT; return UAM_ERROR_NONE; } @@ -949,10 +946,9 @@ int _uam_core_remove_device_by_mac(const char *mac) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + FUNC_EXIT; return UAM_ERROR_NONE; } @@ -1484,10 +1480,9 @@ int _uam_core_init(void) if (UAM_ERROR_NONE != _uam_pm_set_registered_devices(devices)) UAM_ERR("_uam_pm_set_registered_devices failed"); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + FUNC_EXIT; return UAM_ERROR_NONE; } @@ -1630,13 +1625,11 @@ void _uam_core_handle_device_added(int status, UAM_ERR("_uam_pm_set_registered_devices failed"); } -#ifdef VD_REQ _uam_cloud_send_device_added(status, user_id, dev_info); /* Set/update registered device list to cloud plugin */ if (UAM_ERROR_NONE == status) _uam_cloud_set_registered_devices(devices); -#endif FUNC_EXIT; } @@ -1907,9 +1900,8 @@ void _uam_core_reset_database(void) UAM_ERR("_uam_pm_set_registered_devices failed with %s", _uam_manager_error_to_str(ret)); -#ifdef VD_REQ /* Set/update registered device list to cloud plugin */ _uam_cloud_set_registered_devices(devices); -#endif + FUNC_EXIT; } -- 2.7.4 From c025869b5b12b98f8c33f02851f9d4941372df3f Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Thu, 14 Mar 2019 15:54:41 +0530 Subject: [PATCH 12/16] Modified cloud plugin interface and plugin include dir Signed-off-by: Atul Rai --- packaging/ua-manager.spec | 6 ++- ua-daemon/CMakeLists.txt | 2 +- ua-daemon/include/ua-cloud-plugin-handler.h | 4 +- ua-daemon/include/ua-manager-common.h | 2 +- ua-daemon/src/pm/ua-cloud-plugin-handler.c | 20 +++++---- ua-daemon/src/ua-manager-core.c | 18 ++++---- ua-plugins/CMakeLists.txt | 4 +- ua-plugins/include/ua-cloud-plugin.h | 61 +++++-------------------- ua-plugins/include/ua-plugin-type.h | 70 +++++++++++++++++++++++++++++ ua-plugins/ua-plugins.pc.in | 2 +- 10 files changed, 113 insertions(+), 76 deletions(-) create mode 100644 ua-plugins/include/ua-plugin-type.h diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index 29dd4a5..804937a 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -105,7 +105,9 @@ cp ua-manager.service %{buildroot}%{_unitdir}/ua-manager.service %files plugins %defattr(-, root, root) -%{_includedir}/ua-manager/ua-plugin.h -%{_includedir}/ua-manager/ua-power-plugin.h +%{_includedir}/ua-manager/plugins/ua-plugin-type.h +%{_includedir}/ua-manager/plugins/ua-plugin.h +%{_includedir}/ua-manager/plugins/ua-power-plugin.h +%{_includedir}/ua-manager/plugins/ua-cloud-plugin.h %{_libdir}/pkgconfig/ua-plugins.pc diff --git a/ua-daemon/CMakeLists.txt b/ua-daemon/CMakeLists.txt index 7142fcf..cc833a8 100644 --- a/ua-daemon/CMakeLists.txt +++ b/ua-daemon/CMakeLists.txt @@ -19,12 +19,12 @@ SET(SRCS src/pm/ua-wifi-plugin-handler.c src/pm/ua-light-plugin-handler.c src/pm/ua-motion-plugin-handler.c + src/pm/ua-cloud-plugin-handler.c ) IF("$ENV{CFLAGS}" MATCHES "-DVD_REQ") LIST(APPEND SRCS src/pm/ua-power-plugin-manager.c) LIST(APPEND SRCS src/pm/ua-power-plugin-handler.c) - LIST(APPEND SRCS src/pm/ua-cloud-plugin-handler.c) ENDIF() IF("${CMAKE_BUILD_TYPE}" STREQUAL "") diff --git a/ua-daemon/include/ua-cloud-plugin-handler.h b/ua-daemon/include/ua-cloud-plugin-handler.h index 0577963..b21e51f 100644 --- a/ua-daemon/include/ua-cloud-plugin-handler.h +++ b/ua-daemon/include/ua-cloud-plugin-handler.h @@ -22,9 +22,9 @@ extern "C" { #endif -void _uam_cloud_set_registered_devices(GSList *devices); +void _uam_cloud_update_registered_devices(void); -void _uam_cloud_send_device_added(int status, int user_id, +void _uam_cloud_send_device_added(int status, const char *account, const uam_device_info_t *dev_info); #ifdef __cplusplus diff --git a/ua-daemon/include/ua-manager-common.h b/ua-daemon/include/ua-manager-common.h index b838e96..2e30d4b 100644 --- a/ua-daemon/include/ua-manager-common.h +++ b/ua-daemon/include/ua-manager-common.h @@ -57,8 +57,8 @@ extern "C" { #define SENSOR_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/sensor") #ifdef VD_REQ #define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power") -#define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud") #endif +#define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud") #define UAM_VERSION "0.1" diff --git a/ua-daemon/src/pm/ua-cloud-plugin-handler.c b/ua-daemon/src/pm/ua-cloud-plugin-handler.c index 9042236..3aec5e1 100644 --- a/ua-daemon/src/pm/ua-cloud-plugin-handler.c +++ b/ua-daemon/src/pm/ua-cloud-plugin-handler.c @@ -19,6 +19,7 @@ #include #include #include +#include #include typedef struct { @@ -34,7 +35,7 @@ static int add_user(const char *account, const char *name) FUNC_ENTRY; FUNC_EXIT; - return UAC_STATUS_SUCCESS; + return UAP_STATUS_SUCCESS; } static int remove_user(const char *account) @@ -42,23 +43,23 @@ static int remove_user(const char *account) FUNC_ENTRY; FUNC_EXIT; - return UAC_STATUS_SUCCESS; + return UAP_STATUS_SUCCESS; } -static int add_device(const char *account, uac_device_info_t *dev_info) +static int add_device(const char *account, uap_device_info_t *dev_info) { FUNC_ENTRY; FUNC_EXIT; - return UAC_STATUS_SUCCESS; + return UAP_STATUS_SUCCESS; } -static int remove_device(const char *account, char* device_id) +static int remove_device(const char* device_id, int type) { FUNC_ENTRY; FUNC_EXIT; - return UAC_STATUS_SUCCESS; + return UAP_STATUS_SUCCESS; } static void reset_ua_db(void) @@ -76,14 +77,14 @@ uac_callbacks_t cloud_cb = { .reset_cb = reset_ua_db }; -void _uam_cloud_set_registered_devices(GSList *devices) +void _uam_cloud_update_registered_devices(void) { FUNC_ENTRY; FUNC_EXIT; } -void _uam_cloud_send_device_added(int status, int user_id, +void _uam_cloud_send_device_added(int status, const char *account, const uam_device_info_t *dev_info) { FUNC_ENTRY; @@ -199,6 +200,7 @@ static int __load_cloud_plugin(void) static void __deinit_cloud_plugin(void) { FUNC_ENTRY; + ret_if(NULL == cloud_plugin); uac_api_t *api = (uac_api_t *)cloud_plugin->api; uac_module_t *module = (uac_module_t *)cloud_plugin->module; @@ -233,7 +235,7 @@ static int __init_cloud_plugin(void) } status = ((uac_api_t *)cloud_plugin->api)->init(&cloud_cb); - if (UAC_STATUS_SUCCESS != status) { + if (UAP_STATUS_SUCCESS != status) { /* Deinit plugin */ __deinit_cloud_plugin(); return UAM_ERROR_INTERNAL; diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index ae5d0fe..8e25ace 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -241,7 +241,7 @@ static void __free_uam_db_user_info(gpointer data) UAM_ERR("_uam_pm_set_registered_devices failed"); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); __uam_core_release_user_id(user->user_id); g_free(user->name); @@ -815,7 +815,7 @@ int _uam_core_remove_device(const char *account, const uam_device_info_t *dev_in UAM_ERR("_uam_pm_set_registered_devices failed"); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; return UAM_ERROR_NONE; @@ -886,7 +886,7 @@ int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type) UAM_ERR("_uam_pm_set_registered_devices failed"); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; return UAM_ERROR_NONE; @@ -947,7 +947,7 @@ int _uam_core_remove_device_by_mac(const char *mac) UAM_ERR("_uam_pm_set_registered_devices failed"); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; return UAM_ERROR_NONE; @@ -1481,7 +1481,7 @@ int _uam_core_init(void) UAM_ERR("_uam_pm_set_registered_devices failed"); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; return UAM_ERROR_NONE; @@ -1538,6 +1538,7 @@ void _uam_core_handle_device_added(int status, { FUNC_ENTRY; GSList *l; + uam_db_user_info_t *user = NULL; /* Send reply over dbus for add device API */ l = _uam_manager_get_request_list(); @@ -1574,7 +1575,6 @@ void _uam_core_handle_device_added(int status, } if (UAM_ERROR_NONE == status) { - uam_db_user_info_t *user; long long timestamp; if (0 > user_id) { @@ -1625,11 +1625,11 @@ void _uam_core_handle_device_added(int status, UAM_ERR("_uam_pm_set_registered_devices failed"); } - _uam_cloud_send_device_added(status, user_id, dev_info); + _uam_cloud_send_device_added(status, (user ? user->account : NULL), dev_info); /* Set/update registered device list to cloud plugin */ if (UAM_ERROR_NONE == status) - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; } @@ -1901,7 +1901,7 @@ void _uam_core_reset_database(void) _uam_manager_error_to_str(ret)); /* Set/update registered device list to cloud plugin */ - _uam_cloud_set_registered_devices(devices); + _uam_cloud_update_registered_devices(); FUNC_EXIT; } diff --git a/ua-plugins/CMakeLists.txt b/ua-plugins/CMakeLists.txt index 5474290..5b08666 100644 --- a/ua-plugins/CMakeLists.txt +++ b/ua-plugins/CMakeLists.txt @@ -4,12 +4,14 @@ PROJECT(ua-plugins C) SET(LIB_PKGCONFIG_DIR "${LIB_PATH}/pkgconfig") SET(HEADERS + ua-plugin-type.h ua-plugin.h ua-power-plugin.h + ua-cloud-plugin.h ) FOREACH(hfile ${HEADERS}) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${hfile} DESTINATION include/ua-manager) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${hfile} DESTINATION include/ua-manager/plugins/) ENDFOREACH(hfile) SET(PC_NAME ${PROJECT_NAME}) diff --git a/ua-plugins/include/ua-cloud-plugin.h b/ua-plugins/include/ua-cloud-plugin.h index df1281e..63bb802 100644 --- a/ua-plugins/include/ua-cloud-plugin.h +++ b/ua-plugins/include/ua-cloud-plugin.h @@ -18,56 +18,16 @@ #ifndef __UAM_CLOUD_PLUGIN_H__ #define __UAM_CLOUD_PLUGIN_H__ +#include + #ifdef __cplusplus extern "C" { #endif -#define PLUGIN_ID_CLOUD 0x21 - -/* UA power plugin return status */ -typedef enum { - UAC_STATUS_SUCCESS = 0x00, - UAC_STATUS_FAIL = 0x01, - UAC_STATUS_NOT_READY = 0x02, - UAC_STATUS_NOMEM = 0x03, - UAC_STATUS_BUSY = 0x04, - UAC_STATUS_ALREADY_DONE = 0x05, - UAC_STATUS_UNSUPPORTED = 0x06, - UAC_STATUS_TIMEOUT = 0x07, - UAC_STATUS_INVALID_PARAMS = 0x08, -} uac_status_e; - -/* Device Address types */ -typedef enum { - UAC_ADDR_TYPE_BT = 0x01, - UAC_ADDR_TYPE_BLE, - UAC_ADDR_TYPE_WIFI, - UAC_ADDR_TYPE_P2P, - UAC_ADDR_TYPE_IPv4, - UAC_ADDR_TYPE_IPv6, - UAC_ADDR_TYPE_INVALID -} uac_address_type_e; - -/* Device address information structure */ -typedef struct { - uac_address_type_e type; - char *address; -} uac_address_info_t; - -/* Device information structure */ -typedef struct { - int user_id; - unsigned int supported_techs; - char *device_id; - int os; - int num_addr; - uac_address_info_t *addr_list; -} uac_device_info_t; - /* * DIRECTION: Cloud-plugin ---> ua-manager * This callback will be invoked to request user addition in ua database. - * [Param] account - User account id + * [Param] account - User account * [Param] name - User name */ typedef int (*add_user_callback)(const char *account, const char *name); @@ -75,25 +35,25 @@ typedef int (*add_user_callback)(const char *account, const char *name); /* * DIRECTION: Cloud-plugin ---> ua-manager * This callback will be invoked to request user deletion from ua database. - * [Param] account - User account id + * [Param] account - User account */ typedef int (*remove_user_callback)(const char *account); /* * DIRECTION: Cloud-plugin ---> ua-manager * This callback will be invoked to request device addition in ua database. - * [Param] account - Device's user account id + * [Param] account - Device's user account * [Param] dev_info - Device information */ -typedef int (*add_device_callback)(const char *account, uac_device_info_t *dev_info); +typedef int (*add_device_callback)(const char *account, uap_device_info_t *dev_info); /* * DIRECTION: Cloud-plugin ---> ua-manager * This callback will be invoked to request device deletion from ua database. - * [Param] account - Device's user account id * [Param] device_id - Unique device Id + * [Param] type - Device's technology type (BLE/WIFI/...) */ -typedef int (*remove_device_callback)(const char *account, char* device_id); +typedef int (*remove_device_callback)(const char* device_id, int type); /* * DIRECTION: Cloud-plugin ---> ua-manager @@ -131,16 +91,17 @@ typedef struct { * [Param] num_devices - Number of registered devices. * [Param] devices - List of registered devices. */ - int (*set_registered_devices)(int num_devices, uac_device_info_t *devices); + int (*set_registered_devices)(int num_devices, uap_device_info_t *devices); /* * DIRECTION: ua-manager ---> Cloud-plugin * This API is invoked whenever a device is added in ua db. * It is also used to send response for add_device_callback(). * [Param] status - status for device add request + * [Param] account - Device's User account * [Param] dev_info - Device info for added device */ - int (*device_added)(int status, uac_device_info_t *dev_info); + int (*device_added)(int status, const char *account, uap_device_info_t *dev_info); } uac_api_t; typedef struct { diff --git a/ua-plugins/include/ua-plugin-type.h b/ua-plugins/include/ua-plugin-type.h new file mode 100644 index 0000000..d2c9d75 --- /dev/null +++ b/ua-plugins/include/ua-plugin-type.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __UAP_TYPE_H__ +#define __UAP_TYPE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define PLUGIN_ID_CLOUD 0x21 + +#define UAP_MAC_ADDRESS_STRING_LEN 18 +#define UAP_DEVICE_ID_MAX_STRING_LEN 50 +#define UAP_IP_ADDRESS_MAX_STRING_LEN 50 + +typedef enum { + UAP_OS_TYPE_ANDROID = 0x00, + UAP_OS_TYPE_IOS, + UAP_OS_TYPE_TIZEN, + UAP_OS_TYPE_INVALID +} uap_os_type_e; + +typedef enum { + UAP_TECH_TYPE_NONE = 0x00, + UAP_TECH_TYPE_BT = 0x01, + UAP_TECH_TYPE_BLE = 0x02, + UAP_TECH_TYPE_WIFI = 0x04, + UAP_TECH_TYPE_P2P = 0x08, +} uap_tech_type_e; + +typedef struct { + uap_os_type_e os; /* Device's OS */ + uap_tech_type_e type; /* Device's mac address type (BT/BLE/WIFI/P2p/...) */ + char mac[UAP_MAC_ADDRESS_STRING_LEN]; /* Device's MAC ADDRESS */ + char ipv4_addr[UAP_IP_ADDRESS_MAX_STRING_LEN];/* Device's IPv4 address optional */ + char device_id[UAP_DEVICE_ID_MAX_STRING_LEN]; /* Device's uniquie ID */ +} uap_device_info_t; + +/* UA plugin return status */ +typedef enum { + UAP_STATUS_SUCCESS = 0x00, + UAP_STATUS_FAIL = 0x01, + UAP_STATUS_NOT_READY = 0x02, + UAP_STATUS_NOMEM = 0x03, + UAP_STATUS_BUSY = 0x04, + UAP_STATUS_ALREADY_DONE = 0x05, + UAP_STATUS_UNSUPPORTED = 0x06, + UAP_STATUS_TIMEOUT = 0x07, + UAP_STATUS_INVALID_PARAMS = 0x08, +} uap_status_e; + +#ifdef __cplusplus +} +#endif +#endif /* __UAP_TYPE_H__ */ diff --git a/ua-plugins/ua-plugins.pc.in b/ua-plugins/ua-plugins.pc.in index cc97f97..a779c1a 100644 --- a/ua-plugins/ua-plugins.pc.in +++ b/ua-plugins/ua-plugins.pc.in @@ -6,4 +6,4 @@ Name: @PC_NAME@ Description: Samsung Tizen platform User awareness sensor plugin interface Version: @VERSION@ Requires: @PC_REQUIRED@ -Cflags: -I${includedir} -I${includedir}/ua-manager +Cflags: -I${includedir} -I${includedir}/ua-manager/plugins -- 2.7.4 From 595fbe0ad95dc547a1e21cb4691bce8203c45846 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Thu, 14 Mar 2019 15:56:33 +0530 Subject: [PATCH 13/16] Added cloud plugin API and callback implementation Signed-off-by: Atul Rai --- ua-daemon/src/pm/ua-cloud-plugin-handler.c | 112 +++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/ua-daemon/src/pm/ua-cloud-plugin-handler.c b/ua-daemon/src/pm/ua-cloud-plugin-handler.c index 3aec5e1..2d45b6e 100644 --- a/ua-daemon/src/pm/ua-cloud-plugin-handler.c +++ b/ua-daemon/src/pm/ua-cloud-plugin-handler.c @@ -30,9 +30,50 @@ typedef struct { uam_plugin_info_t *cloud_plugin; +static void __uap_to_uam_device_info(uam_device_info_t *dest, + const uap_device_info_t *src) +{ + FUNC_ENTRY; + + ret_if(NULL == src); + ret_if(NULL == dest); + + dest->operating_system = src->os; + dest->type = src->type; + g_strlcpy(dest->device_id, src->device_id, UAM_DEVICE_ID_MAX_STRING_LEN); + g_strlcpy(dest->mac, src->mac, UAM_MAC_ADDRESS_STRING_LEN); + g_strlcpy(dest->ipv4_addr, src->ipv4_addr, UAM_IP_ADDRESS_MAX_STRING_LEN); + + FUNC_EXIT; +} + +static void __uam_to_uap_device_info(uap_device_info_t *dest, + const uam_device_info_t *src) +{ + FUNC_ENTRY; + + ret_if(NULL == src); + ret_if(NULL == dest); + + dest->os = src->operating_system; + dest->type = src->type; + g_strlcpy(dest->device_id, src->device_id, UAP_DEVICE_ID_MAX_STRING_LEN); + g_strlcpy(dest->mac, src->mac, UAP_MAC_ADDRESS_STRING_LEN); + g_strlcpy(dest->ipv4_addr, src->ipv4_addr, UAP_IP_ADDRESS_MAX_STRING_LEN); + + FUNC_EXIT; +} + static int add_user(const char *account, const char *name) { FUNC_ENTRY; + retv_if(NULL == account, UAP_STATUS_INVALID_PARAMS); + retv_if(NULL == name, UAP_STATUS_INVALID_PARAMS); + + if (UAM_ERROR_NONE != _uam_core_add_user(account, name)) { + UAM_ERR("_uam_core_add_user() failed"); + return UAP_STATUS_FAIL; + } FUNC_EXIT; return UAP_STATUS_SUCCESS; @@ -41,6 +82,12 @@ static int add_user(const char *account, const char *name) static int remove_user(const char *account) { FUNC_ENTRY; + retv_if(NULL == account, UAP_STATUS_INVALID_PARAMS); + + if (UAM_ERROR_NONE != _uam_core_remove_user(account)) { + UAM_ERR("_uam_core_remove_user() failed"); + return UAP_STATUS_FAIL; + } FUNC_EXIT; return UAP_STATUS_SUCCESS; @@ -49,6 +96,18 @@ static int remove_user(const char *account) static int add_device(const char *account, uap_device_info_t *dev_info) { FUNC_ENTRY; + uam_device_info_t device; + + retv_if(NULL == account, UAP_STATUS_INVALID_PARAMS); + retv_if(NULL == dev_info, UAP_STATUS_INVALID_PARAMS); + + memset(&device, 0x00, sizeof(uam_device_info_t)); + __uap_to_uam_device_info(&device, dev_info); + + if (UAM_ERROR_NONE != _uam_core_add_device(account, &device)) { + UAM_ERR("_uam_core_remove_user() failed"); + return UAP_STATUS_FAIL; + } FUNC_EXIT; return UAP_STATUS_SUCCESS; @@ -58,6 +117,15 @@ static int remove_device(const char* device_id, int type) { FUNC_ENTRY; + retv_if(NULL == device_id, UAP_STATUS_INVALID_PARAMS); + retv_if(UAP_TECH_TYPE_NONE >= type, UAM_ERROR_INVALID_PARAM); + retv_if(UAP_TECH_TYPE_P2P < type, UAM_ERROR_INVALID_PARAM); + + if (UAM_ERROR_NONE != _uam_core_remove_device_by_device_id(device_id, type)) { + UAM_ERR("_uam_core_remove_user() failed"); + return UAP_STATUS_FAIL; + } + FUNC_EXIT; return UAP_STATUS_SUCCESS; } @@ -80,7 +148,34 @@ uac_callbacks_t cloud_cb = { void _uam_cloud_update_registered_devices(void) { FUNC_ENTRY; + int indx; + uam_device_info_t *devices = NULL; + uap_device_info_t *dev_list = NULL; + int num_devices = 0; + uac_api_t *api; + + ret_if(NULL == cloud_plugin); + + api = (uac_api_t *)cloud_plugin->api; + ret_if(NULL == api); + ret_if(NULL == api->set_registered_devices); + if (UAM_ERROR_NONE != _uam_core_get_devices(&num_devices, &devices)) { + UAM_ERR("_uam_core_get_devices() failed"); + } else { + dev_list = g_new0(uap_device_info_t, num_devices); + for (indx = 0; indx < num_devices; indx++) + __uam_to_uap_device_info(&(dev_list[indx]), &(devices[indx])); + } + + if (!dev_list) + UAM_INFO("No devices in the list"); + + if (UAP_STATUS_SUCCESS != api->set_registered_devices(num_devices, dev_list)) + UAM_ERR("api->set_registered_devices() failed"); + + g_free(devices); + g_free(dev_list); FUNC_EXIT; } @@ -88,6 +183,23 @@ void _uam_cloud_send_device_added(int status, const char *account, const uam_device_info_t *dev_info) { FUNC_ENTRY; + ret_if(NULL == cloud_plugin); + uac_api_t *api = (uac_api_t *)cloud_plugin->api; + uap_device_info_t dev; + + ret_if(NULL == api); + ret_if(NULL == api->device_added); + ret_if(NULL == dev_info); + + if (UAM_ERROR_NONE != status) + status = UAP_STATUS_FAIL; + else + status = UAP_STATUS_SUCCESS; + + memset(&dev, 0x00, sizeof(uap_device_info_t)); + __uam_to_uap_device_info(&dev, dev_info); + if (UAP_STATUS_SUCCESS != api->device_added(status, account, &dev)) + UAM_ERR("api->device_added() failed"); FUNC_EXIT; } -- 2.7.4 From 6540dd872d2f89cf11e6aeeabfd685c7ffe9692e Mon Sep 17 00:00:00 2001 From: Mayank Haarit Date: Thu, 14 Mar 2019 20:59:33 +0530 Subject: [PATCH 14/16] Remove VD_REQ for power plugin related part Change-Id: I22c77430f9c3b01aee1eb92c82a28c74d2ec5664 Signed-off-by: Mayank Haarit --- packaging/ua-manager.spec | 3 --- ua-daemon/CMakeLists.txt | 7 ++----- ua-daemon/include/ua-manager-common.h | 2 -- ua-daemon/src/ua-manager-core.c | 4 ---- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index 804937a..2ec5190 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -49,9 +49,6 @@ cp -a %{SOURCE3} . cp %{SOURCE1001} . %build -%if 0%{?vd_req:1} -export CFLAGS="$CFLAGS -DVD_REQ" -%endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ diff --git a/ua-daemon/CMakeLists.txt b/ua-daemon/CMakeLists.txt index cc833a8..f957f4f 100644 --- a/ua-daemon/CMakeLists.txt +++ b/ua-daemon/CMakeLists.txt @@ -20,13 +20,10 @@ SET(SRCS src/pm/ua-light-plugin-handler.c src/pm/ua-motion-plugin-handler.c src/pm/ua-cloud-plugin-handler.c + src/pm/ua-power-plugin-manager.c + src/pm/ua-power-plugin-handler.c ) -IF("$ENV{CFLAGS}" MATCHES "-DVD_REQ") - LIST(APPEND SRCS src/pm/ua-power-plugin-manager.c) - LIST(APPEND SRCS src/pm/ua-power-plugin-handler.c) -ENDIF() - IF("${CMAKE_BUILD_TYPE}" STREQUAL "") SET(CMAKE_BUILD_TYPE "Release") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") diff --git a/ua-daemon/include/ua-manager-common.h b/ua-daemon/include/ua-manager-common.h index 2e30d4b..0f32d21 100644 --- a/ua-daemon/include/ua-manager-common.h +++ b/ua-daemon/include/ua-manager-common.h @@ -55,9 +55,7 @@ extern "C" { #define FUNC_EXIT UAM_DBG("-") #define SENSOR_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/sensor") -#ifdef VD_REQ #define POWER_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/power") -#endif #define CLOUD_PLUGIN_DIR tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, "network/ua/lib/cloud") #define UAM_VERSION "0.1" diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 8e25ace..5b1a096 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -26,9 +26,7 @@ #include "ua-manager-config-parser.h" #include "ua-cloud-plugin-handler.h" -#ifdef VD_REQ #include "ua-power-plugin-manager.h" -#endif #define UAM_MAX_USERS 255 #define USER_ACCOUNT_DEFAULT "default@default.com" @@ -1645,9 +1643,7 @@ void _uam_core_handle_presence_detected(unsigned int sensor, UAM_INFO("sensor: 0x%8.8X, user_id: %d", sensor, user_id); -#ifdef VD_REQ _uam_ppm_send_presence_detection_event(sensor); -#endif if (NULL == dev_info) { _uam_manager_send_event(NULL, UAM_EVENT_PRESENCE_DETECTED, -- 2.7.4 From da289ee0615fe743443ff1c40b51b381f2578460 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Wed, 20 Mar 2019 16:39:11 +0530 Subject: [PATCH 15/16] Aligned OS type across all interface headers Change-Id: I2d6d44358f350e42d4846709c25a3441454adc04 Signed-off-by: Atul Rai --- include/ua-api.h | 5 +++-- ua-plugins/include/ua-plugin-type.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/ua-api.h b/include/ua-api.h index 9621b8e..12c0127 100644 --- a/include/ua-api.h +++ b/include/ua-api.h @@ -117,9 +117,10 @@ typedef enum { } uam_presence_state_e; typedef enum { - UAM_OS_TYPE_ANDROID = 0x00, - UAM_OS_TYPE_IOS, + UAM_OS_TYPE_UNDEFINED = 0x00, UAM_OS_TYPE_TIZEN, + UAM_OS_TYPE_ANDROID, + UAM_OS_TYPE_IOS, UAM_OS_TYPE_INVALID } uam_os_type_e; diff --git a/ua-plugins/include/ua-plugin-type.h b/ua-plugins/include/ua-plugin-type.h index d2c9d75..e91972b 100644 --- a/ua-plugins/include/ua-plugin-type.h +++ b/ua-plugins/include/ua-plugin-type.h @@ -29,9 +29,10 @@ extern "C" { #define UAP_IP_ADDRESS_MAX_STRING_LEN 50 typedef enum { - UAP_OS_TYPE_ANDROID = 0x00, - UAP_OS_TYPE_IOS, + UAP_OS_TYPE_UNDEFINED = 0x00, UAP_OS_TYPE_TIZEN, + UAP_OS_TYPE_ANDROID, + UAP_OS_TYPE_IOS, UAP_OS_TYPE_INVALID } uap_os_type_e; -- 2.7.4 From c7f8a7deb22fd212d97810bb492384daf7d88d42 Mon Sep 17 00:00:00 2001 From: Atul Rai Date: Wed, 20 Mar 2019 16:42:40 +0530 Subject: [PATCH 16/16] Handle NULL account in add_device_cb from cloud plugin Change-Id: Iebf37b1d4029d23f795f02d27d60ffe349bbcd92 Signed-off-by: Atul Rai --- ua-daemon/src/pm/ua-cloud-plugin-handler.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ua-daemon/src/pm/ua-cloud-plugin-handler.c b/ua-daemon/src/pm/ua-cloud-plugin-handler.c index 2d45b6e..1a98b54 100644 --- a/ua-daemon/src/pm/ua-cloud-plugin-handler.c +++ b/ua-daemon/src/pm/ua-cloud-plugin-handler.c @@ -97,8 +97,17 @@ static int add_device(const char *account, uap_device_info_t *dev_info) { FUNC_ENTRY; uam_device_info_t device; + uam_user_info_t user; + + if (NULL == account) { + if (UAM_ERROR_NONE != _uam_core_get_default_user(&user)) { + UAM_ERR("_uam_core_get_default_user failed"); + return UAP_STATUS_FAIL; + } + + account = user.account; + } - retv_if(NULL == account, UAP_STATUS_INVALID_PARAMS); retv_if(NULL == dev_info, UAP_STATUS_INVALID_PARAMS); memset(&device, 0x00, sizeof(uam_device_info_t)); -- 2.7.4