diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cchecker/UIBackend.h | 2 | ||||
-rw-r--r-- | src/include/cchecker/app.h | 62 | ||||
-rw-r--r-- | src/include/cchecker/certs.h | 65 | ||||
-rw-r--r-- | src/include/cchecker/logic.h | 157 | ||||
-rw-r--r-- | src/include/cchecker/queue.h | 60 | ||||
-rw-r--r-- | src/include/cchecker/sql_query.h | 2 |
6 files changed, 2 insertions, 346 deletions
diff --git a/src/include/cchecker/UIBackend.h b/src/include/cchecker/UIBackend.h index 6133078..659adb8 100644 --- a/src/include/cchecker/UIBackend.h +++ b/src/include/cchecker/UIBackend.h @@ -21,7 +21,7 @@ #pragma once -#include <cchecker/app.h> +#include "service/app.h" namespace CCHECKER { namespace UI { diff --git a/src/include/cchecker/app.h b/src/include/cchecker/app.h deleted file mode 100644 index df4a860..0000000 --- a/src/include/cchecker/app.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ -/* - * @file app.h - * @author Janusz Kozerski (j.kozerski@samsung.com) - * @version 1.0 - * @brief This file is the implementation of app struct - */ -#ifndef CCHECKER_APP_H -#define CCHECKER_APP_H - -#include <string> -#include <list> -#include <sys/types.h> - -namespace CCHECKER { - -// Used as app_id when no information about app id in signal -// Currently in signals from pkgmgr only information about pkg_id is included -const char *const TEMP_APP_ID = "temp#app_id"; - -typedef std::list<std::string> chain_t; -typedef std::list<chain_t> signatures_t; - -struct app_t { - enum class verified_t : int32_t { - NO = 0, - YES = 1, - UNKNOWN = 2 - }; - - std::string app_id; - std::string pkg_id; - uid_t uid; - signatures_t signatures; - verified_t verified; - - app_t(void); - app_t(const std::string &app_id, - const std::string &pkg_id, - uid_t uid, - const signatures_t &signatures); - std::string str(void) const; - std::string str_certs(void) const; -}; - -} //CCHECKER - -#endif //CCHECKER_APP_H diff --git a/src/include/cchecker/certs.h b/src/include/cchecker/certs.h deleted file mode 100644 index 0cb9135..0000000 --- a/src/include/cchecker/certs.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ -/* - * @file certs.h - * @author Janusz Kozerski (j.kozerski@samsung.com) - * @version 1.0 - * @brief This file is the implementation of certificates logic - * Getting out findinf app signature, getting certificates out of - * signature. Checking OCSP - */ - -#ifndef CCHECKER_CERTS_H -#define CCHECKER_CERTS_H - -#include <ckm/ckm-certificate.h> -#include <pkgmgr-info.h> - -#include <cchecker/app.h> -#include <ckm/ckm-manager.h> - -namespace CCHECKER { - -enum sig_t { - AUTHOR_SIG, - DISTRIBUTOR_SIG, - DISTRIBUTOR2_SIG -}; - -class Certs { - public: - enum class ocsp_response_t { - OCSP_APP_OK, - OCSP_APP_REVOKED, - OCSP_CHECK_AGAIN, - OCSP_CERT_ERROR - }; - Certs(); - virtual ~Certs(); - void get_certificates (app_t &app); - ocsp_response_t check_ocsp (const app_t &app); - - protected: // Needed for tests - ocsp_response_t check_ocsp_chain (const chain_t &chain); - - //private: - CKM::ManagerShPtr m_ckm; -}; - -} // CCHECKER - - -#endif // CCHECKER_CERTS_H diff --git a/src/include/cchecker/logic.h b/src/include/cchecker/logic.h deleted file mode 100644 index 888fe07..0000000 --- a/src/include/cchecker/logic.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ -/* - * @file logic.h - * @author Janusz Kozerski (j.kozerski@samsung.com) - * @version 1.0 - * @brief This file is the implementation of SQL queries - */ - -#ifndef CCHECKER_LOGIC_H -#define CCHECKER_LOGIC_H - -#include <condition_variable> -#include <gio/gio.h> -#include <string> -#include <vector> -#include <list> -#include <thread> -#include <memory> - -#include <cchecker/app.h> -#include <cchecker/certs.h> -#include <cchecker/queue.h> - -#include <package-manager.h> -#include <pkgmgr-info.h> - -namespace CCHECKER { - -namespace DB { -class SqlQuery; -} - -enum error_t { - NO_ERROR, - REGISTER_CALLBACK_ERROR, - DBUS_ERROR, - PACKAGE_MANAGER_ERROR, - DATABASE_ERROR, - INTERNAL_ERROR -}; - -enum pkgmgr_event_t { - EVENT_INSTALL, - EVENT_UNINSTALL -}; - -class Logic { - public: - Logic(void); - virtual ~Logic(void); - error_t setup(void); - virtual void clean(void); - - static void connman_callback(GDBusProxy *proxy, - gchar *sender_name, - gchar *signal_name, - GVariant *parameters, - void *logic_ptr); - - protected: - error_t setup_db(); - void load_database_to_buffer(); - - void add_app_to_buffer_and_database(const app_t &app); - void remove_app_from_buffer_and_database(const app_t &app); - - void set_connman_online_state(); - error_t register_dbus_signal_handler(GDBusProxy **proxy, - const char *name, - const char *object_path, - const char *interface_name, - void (*callback) (GDBusProxy *proxy, - gchar *sender_name, - gchar *signal_name, - GVariant *parameters, - void *logic_ptr) - ); - - static int pkgmgrinfo_event_handler_static( - uid_t uid, - int reqid, - const char *pkgtype, - const char *pkgid, - const char *key, - const char *val, - const void *pmsg, - void *data); - - int pkgmgrinfo_event_handler( - uid_t uid, - int reqid, - const char *pkgtype, - const char *pkgid, - const char *key, - const char *val, - const void *pmsg, - void *data); - - int push_pkgmgrinfo_event(uid_t uid, const char *pkgid); - - void push_event(event_t event); - - void process_all(void); - void process_queue(void); - virtual void process_event(const event_t &event); - - bool process_app(app_t& app); - void process_buffer(void); - virtual void app_processed() {}; // for tests - - bool get_online(void) const; - void set_online(bool online); - - bool get_should_exit(void) const; - void set_should_exit(void); - - bool call_ui(const app_t &app); - - Queue m_queue; - Certs m_certs; - std::list<app_t> m_buffer; - DB::SqlQuery *m_sqlquery; - bool m_was_setup_called; - - bool m_is_online; - // TODO: use m_queue for online events - bool m_is_online_enabled; - std::condition_variable m_to_process; - std::mutex m_mutex_cv; - std::thread m_thread; - bool m_should_exit; - - GDBusProxy *m_proxy_connman; - - int m_reqid_install; - int m_reqid_uninstall; - std::unique_ptr<pkgmgrinfo_client, int(*)(pkgmgrinfo_client *)> m_pc_install; - std::unique_ptr<pkgmgrinfo_client, int(*)(pkgmgrinfo_client *)> m_pc_uninstall; -}; - -} // CCHECKER - -#endif //CCHECKER_LOGIC_H diff --git a/src/include/cchecker/queue.h b/src/include/cchecker/queue.h deleted file mode 100644 index 7100265..0000000 --- a/src/include/cchecker/queue.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ -/* - * @file queue.h - * @author Janusz Kozerski (j.kozerski@samsung.com) - * @version 1.0 - * @brief This file is the implementation of thread-safe queue - */ - -#ifndef CCHECKER_QUEUE_H -#define CCHECKER_QUEUE_H - -#include <mutex> -#include <queue> - -#include <cchecker/app.h> - -namespace CCHECKER { - -struct event_t { - enum class event_type_t { - APP_INSTALL, - APP_UNINSTALL, - EVENT_TYPE_UNKNOWN - }; - - event_type_t event_type; - app_t app; - - event_t(); - event_t(const app_t &app, event_type_t type); -}; - -class Queue { - public: - void push_event(const event_t &event); - bool pop_event(event_t &event); - bool empty(); - - private: - std::mutex m_mutex; - std::queue<event_t> m_event_list; -}; - -} // CCHECKER - -#endif // CCHECKER_QUEUE_H diff --git a/src/include/cchecker/sql_query.h b/src/include/cchecker/sql_query.h index fd28fd5..6338561 100644 --- a/src/include/cchecker/sql_query.h +++ b/src/include/cchecker/sql_query.h @@ -24,7 +24,7 @@ #include <string> #include <cchecker/dpl/db/sql_connection.h> -#include <cchecker/app.h> +#include "service/app.h" namespace CCHECKER { namespace DB { |