diff options
Diffstat (limited to 'server/inc')
-rw-r--r-- | server/inc/NotificationServer.h | 43 | ||||
-rw-r--r-- | server/inc/PrivacyInfoService.h | 64 | ||||
-rw-r--r-- | server/inc/PrivacyManagerDaemon.h | 43 | ||||
-rw-r--r-- | server/inc/PrivacyManagerServer.h | 67 | ||||
-rw-r--r-- | server/inc/SocketService.h | 84 | ||||
-rw-r--r-- | server/inc/privacy_manager_daemon.h | 37 |
6 files changed, 338 insertions, 0 deletions
diff --git a/server/inc/NotificationServer.h b/server/inc/NotificationServer.h new file mode 100644 index 0000000..bd91953 --- /dev/null +++ b/server/inc/NotificationServer.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013 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 _NOTIFICATION_SERVER_H_ +#define _NOTIFICATION_SERVER_H_ + +#include <string> +#include <memory> +#include <list> +#include <sqlite3.h> +#include <mutex> +#include <dbus/dbus.h> +#include <gio/gio.h> + +class NotificationServer +{ +private: + bool m_initialized; + GDBusConnection* m_pDBusConnection; +public: + + NotificationServer(void); + ~NotificationServer(void); + int initialize(void); + int notifySettingChanged(const std::string pkgId, const std::string privacyId); + int notifyPkgRemoved(const std::string pkgId); +}; + + +#endif // _NOTIFICATION_SERVER_H_ diff --git a/server/inc/PrivacyInfoService.h b/server/inc/PrivacyInfoService.h new file mode 100644 index 0000000..3fcbde9 --- /dev/null +++ b/server/inc/PrivacyInfoService.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2013 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 _PRIVACY_INFO_SERVICE_H_ +#define _PRIVACY_INFO_SERVICE_H_ + +#include <SocketConnection.h> +#include <SocketService.h> + +class PrivacyInfoService { +private: + inline static std::string getInterfaceName(void) + { + return "PrivacyInfoService"; + } + +public: + static void registerCallbacks(SocketService* pSocketService) + { + pSocketService->registerServiceCallback(getInterfaceName(), std::string("addPrivacyInfo"), addPrivacyInfo); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("removePrivacyInfo"), removePrivacyInfo); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("setPrivacySetting"), setPrivacySetting); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("getPrivacyAppPackages"), getPrivacyAppPackages); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("getAppPackagePrivacyInfo"), getAppPackagePrivacyInfo); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("isUserPrompted"), isUserPrompted); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("setUserPrompted"), setUserPrompted); + pSocketService->registerServiceCallback(getInterfaceName(), std::string("notifyUserNotConsented"), notifyUserNotConsented); + } + + static void addPrivacyInfo(SocketConnection* pConnector); + + static void removePrivacyInfo(SocketConnection* pConnector); + + static void setPrivacySetting(SocketConnection* pConnector); + + // input message format + // interface_name(str) | method_name(str) + // output message format + // result (int) | list size (int) | serialized package list (using delimeter) + static void getPrivacyAppPackages(SocketConnection* pConnector); + + static void getAppPackagePrivacyInfo(SocketConnection* pConnector); + + static void isUserPrompted(SocketConnection* pConnector); + + static void setUserPrompted(SocketConnection* pConnector); + + static void notifyUserNotConsented(SocketConnection* pConnector); + +}; +#endif // _PRIVACY_INFO_SERVICE_H_ diff --git a/server/inc/PrivacyManagerDaemon.h b/server/inc/PrivacyManagerDaemon.h new file mode 100644 index 0000000..a646c8b --- /dev/null +++ b/server/inc/PrivacyManagerDaemon.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013 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 _PRIVACY_MANAGER_DAEMON_H_ +#define _PRIVACY_MANAGER_DAEMON_H_ + +#include <privacy_manager_client_types.h> + +class SocketService; + +class EXTERN_API PrivacyManagerDaemon +{ +private: + static PrivacyManagerDaemon* pInstance; + SocketService* pSocketService; + +private: + PrivacyManagerDaemon(void); + ~PrivacyManagerDaemon(void); + + +public: + static PrivacyManagerDaemon* getInstance(void); + int initialize(void); + int start(void); + int stop(void); + int shutdown(void); +}; + +#endif // _PRIVACY_MANAGER_DAEMON_H_ diff --git a/server/inc/PrivacyManagerServer.h b/server/inc/PrivacyManagerServer.h new file mode 100644 index 0000000..a6534ac --- /dev/null +++ b/server/inc/PrivacyManagerServer.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013 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 _PRIVACY_MANAGER_SERVER_H_ +#define _PRIVACY_MANAGER_SERVER_H_ + +#include <string> +#include <memory> +#include <list> +#include <mutex> +#include <NotificationServer.h> + +class NotificationServer; + +class PrivacyManagerServer +{ +private: + static std::mutex m_singletonMutex; + static PrivacyManagerServer* m_pInstance; + NotificationServer m_notificationServer; + +private: + void createDB(void); + +public: + + explicit PrivacyManagerServer(void); + + virtual ~PrivacyManagerServer(void); + + static PrivacyManagerServer* getInstance(void); + + int getPrivacyAppPackages(std::list <std::string>& list); + + int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > > & list); + + int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled); + + int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList, bool privacyPopupRequired); + + int removeAppPackagePrivacyInfo(const std::string pkgId); + + int isUserPrompted(const std::string pkgId, bool& isPrompted); + + int setUserPrompted(const std::string pkgId, bool prompted); + + int setPermissions(const std::string pkgId, const std::string privacyId, bool enabled); + + int notifyUserNotConsented(const std::string pkgId, const std::string privacyId); + +}; + + +#endif // _PRIVACY_MANAGER_SERVER_H_ diff --git a/server/inc/SocketService.h b/server/inc/SocketService.h new file mode 100644 index 0000000..50fc0e6 --- /dev/null +++ b/server/inc/SocketService.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013 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 _SOCKET_SERVICE_H_ +#define _SOCKET_SERVICE_H_ + +#include <string> +#include <mutex> +#include <list> +#include <map> +#include <memory> +#include <pthread.h> +#include <SocketConnection.h> + +typedef void(*socketServiceCallback)(SocketConnection* pConnector); + +class SocketService +{ + struct ConnectionInfo{ + ConnectionInfo(int fd, void* pData) : connFd(fd), pData(pData) {} + int connFd; + void* pData; + }; + class ServiceCallback + { + public: + ServiceCallback(socketServiceCallback callback) + : serviceCallback(callback) + {} + socketServiceCallback serviceCallback; + }; + +private: + static const int MAX_LISTEN; + static const int TIMEOUT_SEC; + static const int TIMEOUT_NSEC; + int m_listenFd; + int m_signalToClose; + pthread_t m_mainThread; + + typedef std::shared_ptr<ServiceCallback> ServiceCallbackPtr; + //Map for callback methods, key is a method name and value is a callback to method + typedef std::map<std::string, ServiceCallbackPtr> ServiceMethodCallbackMap; + //Map for interface methods, key is an interface name and value is a map of available methods with callbacks + std::map <std::string, ServiceMethodCallbackMap > m_callbackMap; + + std::list < int > m_clientSocketList; + std::mutex m_clientSocketListMutex; + +private: + static void* serverThread(void* ); + static void* connectionThread(void* pData); + int connectionService(int fd); + int mainloop(void); + void closeConnections(void); + + void addClientSocket(int clientSocket); + void removeClientSocket(int clientSocket); + bool popClientSocket(int* pClientSocket); + +public: + SocketService(void); + ~SocketService(void); + int initialize(void); + int registerServiceCallback(const std::string &interfaceName, const std::string &methodName, socketServiceCallback callbackMethod); + int start(void); + int stop(void); + int shutdown(void); +}; + +#endif //_SOCKET_SERVICE_H_
\ No newline at end of file diff --git a/server/inc/privacy_manager_daemon.h b/server/inc/privacy_manager_daemon.h new file mode 100644 index 0000000..70e39da --- /dev/null +++ b/server/inc/privacy_manager_daemon.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013 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 __PRIVACY_MANAGER_DAEMON_H__ +#define __PRIVACY_MANAGER_DAEMON_H__ + +#include <privacy_manager_client_types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +int EXTERN_API privacy_manager_daemon_initialize(void); +int EXTERN_API privacy_manager_daemon_start(void); +int EXTERN_API privacy_manager_daemon_stop(void); +int EXTERN_API privacy_manager_daemon_shutdown(void); + +#ifdef __cplusplus +} +#endif + + +#endif //__PRIVACY_MANAGER_DAEMON_H__ + |