diff options
Diffstat (limited to 'trunk/include')
-rw-r--r-- | trunk/include/AbstractConversationListModel.hpp | 22 | ||||
-rw-r--r-- | trunk/include/AbstractConversationModel.hpp | 22 | ||||
-rw-r--r-- | trunk/include/AbstractFriendListModel.hpp | 31 | ||||
-rw-r--r-- | trunk/include/AbstractIdentityListModel.hpp | 26 | ||||
-rw-r--r-- | trunk/include/AbstractSecushareController.hpp | 131 | ||||
-rw-r--r-- | trunk/include/AbstractSecushareView.hpp | 124 | ||||
-rw-r--r-- | trunk/include/AbstractUserConfigModel.hpp | 24 | ||||
-rw-r--r-- | trunk/include/AbstractUserInfoListModel.hpp | 19 | ||||
-rw-r--r-- | trunk/include/AbstractUserInfoModel.hpp | 35 | ||||
-rw-r--r-- | trunk/include/Identity.hpp | 49 | ||||
-rw-r--r-- | trunk/include/NotifyPipe.hpp | 23 | ||||
-rw-r--r-- | trunk/include/Place.hpp | 36 | ||||
-rw-r--r-- | trunk/include/QtUserConfigModel.hpp | 28 | ||||
-rw-r--r-- | trunk/include/RedThreadQt.hpp | 39 | ||||
-rw-r--r-- | trunk/include/SecushareQtController.hpp | 41 | ||||
-rw-r--r-- | trunk/include/SecushareQtView.hpp | 56 | ||||
-rw-r--r-- | trunk/include/Signal.hpp | 26 |
17 files changed, 732 insertions, 0 deletions
diff --git a/trunk/include/AbstractConversationListModel.hpp b/trunk/include/AbstractConversationListModel.hpp new file mode 100644 index 0000000..67929fb --- /dev/null +++ b/trunk/include/AbstractConversationListModel.hpp | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_CONVERSATION_LIST_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_CONVERSATION_LIST_MODEL__H | ||
3 | |||
4 | #include "Place.hpp" | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractConversationListModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | AbstractConversationListModel() { } | ||
13 | virtual ~AbstractConversationListModel() { } | ||
14 | |||
15 | virtual void addConversation(const Place& place) = 0; | ||
16 | |||
17 | private: | ||
18 | //////// | ||
19 | }; | ||
20 | } | ||
21 | |||
22 | #endif | ||
diff --git a/trunk/include/AbstractConversationModel.hpp b/trunk/include/AbstractConversationModel.hpp new file mode 100644 index 0000000..aaaf802 --- /dev/null +++ b/trunk/include/AbstractConversationModel.hpp | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_CONVERSATION_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_CONVERSATION_MODEL__H | ||
3 | |||
4 | #include "Place.hpp" | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractConversationModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | AbstractConversationModel(); | ||
13 | virtual ~AbstractConversationModel() { } | ||
14 | |||
15 | virtual Place getRootPlace() const = 0; | ||
16 | |||
17 | private: | ||
18 | //////// | ||
19 | }; | ||
20 | } | ||
21 | |||
22 | #endif | ||
diff --git a/trunk/include/AbstractFriendListModel.hpp b/trunk/include/AbstractFriendListModel.hpp new file mode 100644 index 0000000..f5e8db8 --- /dev/null +++ b/trunk/include/AbstractFriendListModel.hpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_FRIEND_LIST_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_FRIEND_LIST_MODEL__H | ||
3 | |||
4 | #include "Identity.hpp" | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractFriendListModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | using IdentityId = Identity::IdentityId; | ||
13 | |||
14 | AbstractFriendListModel() { } | ||
15 | virtual ~AbstractFriendListModel() { } | ||
16 | |||
17 | /** | ||
18 | * add a friend to the circle of a specific ego | ||
19 | */ | ||
20 | virtual void addFriend(const Identity& identity, | ||
21 | const Identity& ego) = 0; | ||
22 | |||
23 | virtual Identity getFriend(const IdentityId& friendId, | ||
24 | const IdentityId& ego) = 0; | ||
25 | |||
26 | private: | ||
27 | //////// | ||
28 | }; | ||
29 | } | ||
30 | |||
31 | #endif | ||
diff --git a/trunk/include/AbstractIdentityListModel.hpp b/trunk/include/AbstractIdentityListModel.hpp new file mode 100644 index 0000000..94162a4 --- /dev/null +++ b/trunk/include/AbstractIdentityListModel.hpp | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_IDENTITY_LIST_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_IDENTITY_LIST_MODEL__H | ||
3 | |||
4 | #include "Identity.hpp" | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractIdentityListModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | using IdentityId = Identity::IdentityId; | ||
13 | |||
14 | AbstractIdentityListModel() { } | ||
15 | virtual ~AbstractIdentityListModel() { } | ||
16 | |||
17 | virtual void addIdentity(const Identity& identitiy) = 0; | ||
18 | |||
19 | virtual Identity getIdentity(const IdentityId& id) = 0; | ||
20 | |||
21 | private: | ||
22 | //////// | ||
23 | }; | ||
24 | } | ||
25 | |||
26 | #endif | ||
diff --git a/trunk/include/AbstractSecushareController.hpp b/trunk/include/AbstractSecushareController.hpp new file mode 100644 index 0000000..a6b08c4 --- /dev/null +++ b/trunk/include/AbstractSecushareController.hpp | |||
@@ -0,0 +1,131 @@ | |||
1 | /** | ||
2 | * @file AbstractSecushareController.hpp | ||
3 | * @brief Abstract controller class | ||
4 | * | ||
5 | * @author lurchi | ||
6 | * @date 2016-02-05 | ||
7 | * | ||
8 | * @copyright | ||
9 | * This file is part of redthread which may be redistributed and/or modified | ||
10 | * under the terms of the GNU General Public License, either version 3 or any | ||
11 | * later version. See COPYING and <http://www.gnu.org/licenses/>. | ||
12 | * | ||
13 | * @todo remove appName, appVersion, configPath as arguments and get them from config.h / somewhere else | ||
14 | |||
15 | */ | ||
16 | |||
17 | #ifndef REDTHREAD_ABSTRACT_SECUSHARE_CONTROLLER__H | ||
18 | #define REDTHREAD_ABSTRACT_SECUSHARE_CONTROLLER__H | ||
19 | |||
20 | #include "AbstractSecushareView.hpp" | ||
21 | #include "NotifyPipe.hpp" | ||
22 | #include <string> | ||
23 | #include <queue> | ||
24 | #include <mutex> | ||
25 | |||
26 | extern "C" | ||
27 | { | ||
28 | #include <gnunet/platform.h> | ||
29 | #include <gnunet/gnunet_util_lib.h> | ||
30 | #include <gnunet/gnunet_psyc_util_lib.h> | ||
31 | #include <gnunet/gnunet_social_service.h> | ||
32 | } | ||
33 | |||
34 | namespace redthread | ||
35 | { | ||
36 | class AbstractSecushareController | ||
37 | { | ||
38 | public: | ||
39 | /////// | ||
40 | using PlaceId = Place::PlaceId; | ||
41 | using IdentityId = Identity::IdentityId; | ||
42 | |||
43 | int run(); | ||
44 | |||
45 | protected: | ||
46 | ////////// | ||
47 | AbstractSecushareController( | ||
48 | std::shared_ptr<AbstractSecushareView> view, | ||
49 | const std::string& appName, | ||
50 | const std::string& appVersion, | ||
51 | const std::string& configPath | ||
52 | ); | ||
53 | |||
54 | virtual ~AbstractSecushareController() { } | ||
55 | |||
56 | // slots | ||
57 | void shutdown(); | ||
58 | void addEgo(const std::string& name); | ||
59 | void addFriend(const std::string& nymPubKey, const std::string& name); | ||
60 | void sendMessage(const PlaceId& placeId, const std::string& message); | ||
61 | |||
62 | private: | ||
63 | //////// | ||
64 | std::shared_ptr<AbstractSecushareView> mView; | ||
65 | std::string mAppName; | ||
66 | std::string mAppVersion; | ||
67 | std::string mConfigFilePath; | ||
68 | bool mRunning; | ||
69 | |||
70 | /** | ||
71 | * gnunet task queue | ||
72 | * | ||
73 | * must be locked because it will be accessed by gnunet thread and view thread | ||
74 | */ | ||
75 | std::queue<std::function<void()>> mGnunetTasks; | ||
76 | std::mutex mGnunetTasksMutex; | ||
77 | Util::NotifyPipe mGnunetTaskPipe; | ||
78 | |||
79 | const struct GNUNET_CONFIGURATION_Handle *mConfigHandle; | ||
80 | struct GNUNET_SOCIAL_App* mAppHandle; | ||
81 | struct GNUNET_IDENTITY_Handle* mIdentityHandle; | ||
82 | struct GNUNET_SCHEDULER_Task* mExternalEventFdHandle; | ||
83 | |||
84 | void addExternalEventFD(); | ||
85 | void addToGnunetTaskQueue(std::function<void()> task); | ||
86 | |||
87 | static void processGnunetTasksCb( | ||
88 | void* closure, | ||
89 | const struct GNUNET_SCHEDULER_TaskContext* tc | ||
90 | ); | ||
91 | |||
92 | static void runCb( | ||
93 | void* closure, | ||
94 | char* const* args, | ||
95 | const char* configFilePath, | ||
96 | const struct GNUNET_CONFIGURATION_Handle* configHandle | ||
97 | ); | ||
98 | |||
99 | static void egoAvailableCb( | ||
100 | void* closure, | ||
101 | struct GNUNET_SOCIAL_Ego* ego, | ||
102 | const struct GNUNET_CRYPTO_EcdsaPublicKey* egoPubKey, | ||
103 | const char* name | ||
104 | ); | ||
105 | |||
106 | static void placeAvailableAsHostCb( | ||
107 | void* closure, | ||
108 | struct GNUNET_SOCIAL_HostConnection* connection, | ||
109 | struct GNUNET_SOCIAL_Ego* ego, | ||
110 | const struct GNUNET_CRYPTO_EddsaPublicKey* hostPubKey, | ||
111 | enum GNUNET_SOCIAL_PlaceState placeState | ||
112 | ); | ||
113 | |||
114 | static void placeAvailableAsGuestCb( | ||
115 | void* closure, | ||
116 | struct GNUNET_SOCIAL_GuestConnection* connection, | ||
117 | struct GNUNET_SOCIAL_Ego* ego, | ||
118 | const struct GNUNET_CRYPTO_EddsaPublicKey* guestPubKey, | ||
119 | enum GNUNET_SOCIAL_PlaceState placeState | ||
120 | ); | ||
121 | |||
122 | static void egoCreatedCb(void *closure, | ||
123 | struct GNUNET_IDENTITY_Ego* ego, | ||
124 | void** ctx, | ||
125 | const char* name); | ||
126 | |||
127 | static void operationFinishedCb(void* closure, const char* errorMessage); | ||
128 | }; | ||
129 | } | ||
130 | |||
131 | #endif | ||
diff --git a/trunk/include/AbstractSecushareView.hpp b/trunk/include/AbstractSecushareView.hpp new file mode 100644 index 0000000..e500678 --- /dev/null +++ b/trunk/include/AbstractSecushareView.hpp | |||
@@ -0,0 +1,124 @@ | |||
1 | // AbstractSecushareView.hpp | ||
2 | // | ||
3 | // author: lurchi | ||
4 | // date: 2016-02-05 | ||
5 | |||
6 | #ifndef REDTHREAD_ABSTRACT_SECUSHARE_VIEW__H | ||
7 | #define REDTHREAD_ABSTRACT_SECUSHARE_VIEW__H | ||
8 | |||
9 | #include "AbstractUserConfigModel.hpp" | ||
10 | #include "AbstractIdentityListModel.hpp" | ||
11 | #include "AbstractUserInfoListModel.hpp" | ||
12 | #include "AbstractUserInfoModel.hpp" | ||
13 | #include "AbstractConversationListModel.hpp" | ||
14 | #include "AbstractConversationModel.hpp" | ||
15 | #include "AbstractFriendListModel.hpp" | ||
16 | #include <string> | ||
17 | #include <memory> | ||
18 | |||
19 | namespace redthread | ||
20 | { | ||
21 | class AbstractSecushareView | ||
22 | { | ||
23 | public: | ||
24 | /////// | ||
25 | using IdentityId = Identity::IdentityId; | ||
26 | using PlaceId = Place::PlaceId; | ||
27 | |||
28 | virtual int run() = 0; | ||
29 | |||
30 | /** | ||
31 | * Models | ||
32 | * | ||
33 | * The lifetime of the models is managed by the View (class inheriting from | ||
34 | * AbstractSecushareView). Other classes such as the Controller will modify but | ||
35 | * never remove models. When the view knows a model is not needed anymore | ||
36 | * it can call the removeItem method of the *ListModel classes. It must never | ||
37 | * call delete on the models directly. | ||
38 | * | ||
39 | * The model classes' getters and setters are thread-safe. | ||
40 | */ | ||
41 | |||
42 | /** | ||
43 | * @brief the user-defined configuration | ||
44 | * | ||
45 | * should be initialized by control before run is called | ||
46 | */ | ||
47 | virtual std::shared_ptr<AbstractUserConfigModel> getUserConfigModel() const | ||
48 | {return nullptr;} | ||
49 | |||
50 | /** | ||
51 | * @brief our egos | ||
52 | * | ||
53 | * used for different social circles | ||
54 | */ | ||
55 | virtual std::shared_ptr<AbstractIdentityListModel> getEgoListModel() const | ||
56 | {return nullptr;} | ||
57 | |||
58 | /** | ||
59 | * @brief the history of our UserInfo (of all our egos) | ||
60 | */ | ||
61 | virtual std::shared_ptr<AbstractUserInfoListModel> | ||
62 | getUserInfoListModel() const | ||
63 | {return nullptr;} | ||
64 | |||
65 | /** | ||
66 | * @brief a specific ego's latest UserInfo | ||
67 | */ | ||
68 | virtual std::shared_ptr<AbstractUserInfoModel> | ||
69 | getLatestUserInfoModel(IdentityId egoId) const | ||
70 | {return nullptr;} | ||
71 | |||
72 | /** | ||
73 | * @brief currently relevant conversations (hosted by us or by friends) | ||
74 | */ | ||
75 | virtual std::shared_ptr<AbstractConversationListModel> | ||
76 | getConversationListModel() const | ||
77 | {return nullptr;} | ||
78 | |||
79 | /** | ||
80 | * @brief a specific place's conversation | ||
81 | */ | ||
82 | virtual std::shared_ptr<AbstractConversationModel> | ||
83 | getConversationModel(const PlaceId& rootPlace) const | ||
84 | {return nullptr;} | ||
85 | |||
86 | /** | ||
87 | * @brief our friends (of all our egos) | ||
88 | */ | ||
89 | virtual std::shared_ptr<AbstractFriendListModel> | ||
90 | getFriendListModel() const | ||
91 | {return nullptr;} | ||
92 | |||
93 | /** | ||
94 | * @brief the history of a specific friend's UserInfo | ||
95 | */ | ||
96 | virtual std::shared_ptr<AbstractUserInfoListModel> | ||
97 | getFriendUserInfoListModel(const IdentityId& nymId) const | ||
98 | {return nullptr;} | ||
99 | |||
100 | /** | ||
101 | * @brief a specific friend's latest UserInfo | ||
102 | */ | ||
103 | virtual std::shared_ptr<AbstractUserInfoModel> | ||
104 | getFriendLatestUserInfoModel(const IdentityId& nymId) const | ||
105 | {return nullptr;} | ||
106 | |||
107 | /** | ||
108 | * @brief a specific friend's friends | ||
109 | */ | ||
110 | virtual std::shared_ptr<AbstractIdentityListModel> | ||
111 | getFriendFriendListModel(const IdentityId& nymId) const | ||
112 | {return nullptr;} | ||
113 | |||
114 | protected: | ||
115 | ////////// | ||
116 | AbstractSecushareView(); | ||
117 | virtual ~AbstractSecushareView() { } | ||
118 | |||
119 | private: | ||
120 | //////// | ||
121 | }; | ||
122 | } | ||
123 | |||
124 | #endif | ||
diff --git a/trunk/include/AbstractUserConfigModel.hpp b/trunk/include/AbstractUserConfigModel.hpp new file mode 100644 index 0000000..858efbe --- /dev/null +++ b/trunk/include/AbstractUserConfigModel.hpp | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_USER_CONFIG_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_USER_CONFIG_MODEL__H | ||
3 | |||
4 | #include <atomic> | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractUserConfigModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | AbstractUserConfigModel(); | ||
13 | virtual ~AbstractUserConfigModel() { } | ||
14 | |||
15 | bool getShowNewIdentityDialog() const {return mShowNewIdentityDialog;} | ||
16 | void setShowNewIdentityDialog(bool value) {mShowNewIdentityDialog = value;} | ||
17 | |||
18 | private: | ||
19 | //////// | ||
20 | std::atomic<bool> mShowNewIdentityDialog; | ||
21 | }; | ||
22 | } | ||
23 | |||
24 | #endif | ||
diff --git a/trunk/include/AbstractUserInfoListModel.hpp b/trunk/include/AbstractUserInfoListModel.hpp new file mode 100644 index 0000000..e155af7 --- /dev/null +++ b/trunk/include/AbstractUserInfoListModel.hpp | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_USER_INFO_LIST_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_USER_INFO_LIST_MDOEL__H | ||
3 | |||
4 | namespace redthread | ||
5 | { | ||
6 | class AbstractUserInfoListModel | ||
7 | { | ||
8 | public: | ||
9 | /////// | ||
10 | AbstractUserInfoListModel() { } | ||
11 | virtual ~AbstractUserInfoListModel() { } | ||
12 | |||
13 | |||
14 | private: | ||
15 | //////// | ||
16 | }; | ||
17 | } | ||
18 | |||
19 | #endif | ||
diff --git a/trunk/include/AbstractUserInfoModel.hpp b/trunk/include/AbstractUserInfoModel.hpp new file mode 100644 index 0000000..96ea1e1 --- /dev/null +++ b/trunk/include/AbstractUserInfoModel.hpp | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef REDTHREAD_ABSTRACT_USER_INFO_MODEL__H | ||
2 | #define REDTHREAD_ABSTRACT_USER_INFO_MODEL__H | ||
3 | |||
4 | #include "Place.hpp" | ||
5 | |||
6 | namespace redthread | ||
7 | { | ||
8 | class AbstractUserInfoModel | ||
9 | { | ||
10 | public: | ||
11 | /////// | ||
12 | using PlaceId = Place::PlaceId; | ||
13 | |||
14 | AbstractUserInfoModel() { } | ||
15 | virtual ~AbstractUserInfoModel() { } | ||
16 | |||
17 | virtual void | ||
18 | setStatus(const std::string& pubKey, const std::string& status) = 0; | ||
19 | |||
20 | virtual void | ||
21 | setMood(const std::string& pubKey, const std::string& mood) = 0; | ||
22 | |||
23 | virtual void setDefaultPlace(const PlaceId& place) = 0; | ||
24 | |||
25 | virtual std::string getStatus() = 0; | ||
26 | virtual std::string getMood() = 0; | ||
27 | |||
28 | virtual PlaceId getDefaultPlace() const = 0; | ||
29 | |||
30 | private: | ||
31 | //////// | ||
32 | }; | ||
33 | } | ||
34 | |||
35 | #endif | ||
diff --git a/trunk/include/Identity.hpp b/trunk/include/Identity.hpp new file mode 100644 index 0000000..4e7d059 --- /dev/null +++ b/trunk/include/Identity.hpp | |||
@@ -0,0 +1,49 @@ | |||
1 | // Identity.hpp | ||
2 | // | ||
3 | // author: lurchi | ||
4 | // date: 2016-02-01 | ||
5 | |||
6 | #ifndef REDTHREAD_IDENTITY__H | ||
7 | #define REDTHREAD_IDENTITY__H | ||
8 | |||
9 | #include <string> | ||
10 | #include <vector> | ||
11 | |||
12 | namespace redthread | ||
13 | { | ||
14 | class Identity | ||
15 | { | ||
16 | public: | ||
17 | /////// | ||
18 | using IdentityId = std::string; | ||
19 | |||
20 | Identity(const std::string& masterPubKey = "", | ||
21 | const std::vector<std::string>& subordinatePubKeys = {}); | ||
22 | |||
23 | bool isValid() const {return not mMasterPubKey.empty();} | ||
24 | |||
25 | IdentityId getId() const {return mMasterPubKey;} | ||
26 | |||
27 | std::string getMasterPubKey() const {return mMasterPubKey;} | ||
28 | |||
29 | std::vector<std::string> getSubordinatePubKeys() const | ||
30 | {return mSubordinatePubKeys;} | ||
31 | |||
32 | std::string getName() const {return mName;} | ||
33 | |||
34 | void setMasterPubKey(const std::string& key) {mMasterPubKey = key;} | ||
35 | |||
36 | void setSubOrdinatePubKeys(const std::vector<std::string>& keys) | ||
37 | {mSubordinatePubKeys = keys;} | ||
38 | |||
39 | bool operator==(const Identity& other) const; | ||
40 | |||
41 | private: | ||
42 | //////// | ||
43 | std::string mMasterPubKey; | ||
44 | std::vector<std::string> mSubordinatePubKeys; | ||
45 | std::string mName; | ||
46 | }; | ||
47 | } | ||
48 | |||
49 | #endif | ||
diff --git a/trunk/include/NotifyPipe.hpp b/trunk/include/NotifyPipe.hpp new file mode 100644 index 0000000..3605efc --- /dev/null +++ b/trunk/include/NotifyPipe.hpp | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef UTIL_NOTIFY_PIPE__H | ||
2 | #define UTIL_NOTIFY_PIPE__H | ||
3 | |||
4 | namespace Util | ||
5 | { | ||
6 | class NotifyPipe | ||
7 | { | ||
8 | public: | ||
9 | /////// | ||
10 | NotifyPipe(); | ||
11 | virtual ~NotifyPipe(); | ||
12 | |||
13 | int receiverFd(); | ||
14 | void notify(); | ||
15 | |||
16 | private: | ||
17 | //////// | ||
18 | int m_receiveFd; | ||
19 | int m_sendFd; | ||
20 | }; | ||
21 | } | ||
22 | |||
23 | #endif | ||
diff --git a/trunk/include/Place.hpp b/trunk/include/Place.hpp new file mode 100644 index 0000000..31b3ef9 --- /dev/null +++ b/trunk/include/Place.hpp | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef REDTHREAD_PLACE__H | ||
2 | #define REDTHREAD_PLACE__H | ||
3 | |||
4 | #include "Identity.hpp" | ||
5 | #include <string> | ||
6 | |||
7 | namespace redthread | ||
8 | { | ||
9 | class Place | ||
10 | { | ||
11 | public: | ||
12 | /////// | ||
13 | using PlaceId = std::string; | ||
14 | using IdentityId = Identity::IdentityId; | ||
15 | |||
16 | Place(const std::string& pubKey = "", const IdentityId& owner = {}); | ||
17 | |||
18 | bool isValid() const {return not (mPubKey.empty() or mOwner.isValid());} | ||
19 | |||
20 | std::string getPubKey() const {return mPubKey;} | ||
21 | Identity getOwner() const {return mOwner;} | ||
22 | |||
23 | void setPubKey(const std::string& key) {mPubKey = key;} | ||
24 | void setOwner(const Identity& owner) {mOwner = owner;} | ||
25 | |||
26 | bool operator==(const Place& other) const | ||
27 | {return mPubKey == other.mPubKey and mOwner == other.mOwner;} | ||
28 | |||
29 | private: | ||
30 | //////// | ||
31 | std::string mPubKey; | ||
32 | Identity mOwner; | ||
33 | }; | ||
34 | } | ||
35 | |||
36 | #endif | ||
diff --git a/trunk/include/QtUserConfigModel.hpp b/trunk/include/QtUserConfigModel.hpp new file mode 100644 index 0000000..c11083c --- /dev/null +++ b/trunk/include/QtUserConfigModel.hpp | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef REDTHREAD_QT_USER_CONFIG_MODEL__H | ||
2 | #define REDTHREAD_QT_USER_CONFIG_MODEL__H | ||
3 | |||
4 | #include "AbstractUserConfigModel.hpp" | ||
5 | #include <QAbstractItemModel> | ||
6 | |||
7 | namespace redthread | ||
8 | { | ||
9 | class QtUserConfigModel : public QAbstractItemModel, | ||
10 | public AbstractUserConfigModel | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | /////// | ||
16 | QtUserConfigModel(QObject* parent = nullptr); | ||
17 | ~QtUserConfigModel() override; | ||
18 | |||
19 | int columnCount(const QModelIndex & parent = QModelIndex()) const override; | ||
20 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; | ||
21 | QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override; | ||
22 | QModelIndex parent(const QModelIndex & index) const override; | ||
23 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; | ||
24 | |||
25 | }; | ||
26 | } | ||
27 | |||
28 | #endif | ||
diff --git a/trunk/include/RedThreadQt.hpp b/trunk/include/RedThreadQt.hpp new file mode 100644 index 0000000..500f895 --- /dev/null +++ b/trunk/include/RedThreadQt.hpp | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef REDTHREAD_REDTHREAD_QT__H | ||
2 | #define REDTHREAD_REDTHREAD_QT__H | ||
3 | |||
4 | #include "SecushareQtView.hpp" | ||
5 | #include "SecushareQtController.hpp" | ||
6 | #include <vector> | ||
7 | #include <thread> | ||
8 | #include <iostream> | ||
9 | |||
10 | namespace redthread | ||
11 | { | ||
12 | class RedThreadQt | ||
13 | { | ||
14 | public: | ||
15 | /////// | ||
16 | RedThreadQt(int argc, char** argv); | ||
17 | ~RedThreadQt(); | ||
18 | |||
19 | /** | ||
20 | * @brief run the event loops | ||
21 | * | ||
22 | * SecushareQtControl's run method is called in a thread which starts | ||
23 | * gnunet's event loop. After that SecushareQtView's run method is | ||
24 | * called which starts Qt's event loop. It returns when the QApplication | ||
25 | * quits. | ||
26 | * | ||
27 | * @return 0 on normal exit, another value on error | ||
28 | */ | ||
29 | int run(); | ||
30 | |||
31 | private: | ||
32 | //////// | ||
33 | std::shared_ptr<SecushareQtView> mView; | ||
34 | SecushareQtController mController; | ||
35 | std::thread mControlThread; | ||
36 | }; | ||
37 | } | ||
38 | |||
39 | #endif | ||
diff --git a/trunk/include/SecushareQtController.hpp b/trunk/include/SecushareQtController.hpp new file mode 100644 index 0000000..cecab89 --- /dev/null +++ b/trunk/include/SecushareQtController.hpp | |||
@@ -0,0 +1,41 @@ | |||
1 | // SecushareQtController.hpp | ||
2 | // | ||
3 | // author: lurchi | ||
4 | // date: 2016-02-01 | ||
5 | |||
6 | #ifndef REDTHREAD_SECUSHARE_CONTROLLER__H | ||
7 | #define REDTHREAD_SECUSHARE_CONTROLLER__H | ||
8 | |||
9 | #include "AbstractSecushareController.hpp" | ||
10 | #include "SecushareQtView.hpp" | ||
11 | #include <QObject> | ||
12 | |||
13 | namespace redthread | ||
14 | { | ||
15 | class SecushareQtController : public QObject, public AbstractSecushareController | ||
16 | { | ||
17 | Q_OBJECT | ||
18 | |||
19 | public: | ||
20 | /////// | ||
21 | SecushareQtController(std::shared_ptr<SecushareQtView> view, | ||
22 | const std::string& appName, | ||
23 | const std::string& appVersion, | ||
24 | const std::string& configPath, | ||
25 | QObject* parent = nullptr); | ||
26 | |||
27 | ~SecushareQtController() override; | ||
28 | |||
29 | public slots: | ||
30 | ///////////// | ||
31 | void shutdown(); | ||
32 | void addEgo(const std::string& name); | ||
33 | void addFriend(const std::string& nymPubKey, const std::string& name); | ||
34 | void sendMessage(const PlaceId& placeId, const std::string& message); | ||
35 | |||
36 | private: | ||
37 | //////// | ||
38 | }; | ||
39 | } | ||
40 | |||
41 | #endif | ||
diff --git a/trunk/include/SecushareQtView.hpp b/trunk/include/SecushareQtView.hpp new file mode 100644 index 0000000..d5c118d --- /dev/null +++ b/trunk/include/SecushareQtView.hpp | |||
@@ -0,0 +1,56 @@ | |||
1 | // SecushareQtView.hpp | ||
2 | // | ||
3 | // author: lurchi | ||
4 | // date: 2016-02-01 | ||
5 | |||
6 | #ifndef REDTHREAD_SECUSHARE_VIEW__H | ||
7 | #define REDTHREAD_SECUSHARE_VIEW__H | ||
8 | |||
9 | #include "AbstractSecushareView.hpp" | ||
10 | #include "QtUserConfigModel.hpp" | ||
11 | #include "NotifyPipe.hpp" | ||
12 | #include <QApplication> | ||
13 | #include <QSocketNotifier> | ||
14 | #include <vector> | ||
15 | #include <iostream> | ||
16 | |||
17 | namespace redthread | ||
18 | { | ||
19 | class SecushareQtView : public QObject, public AbstractSecushareView | ||
20 | { | ||
21 | Q_OBJECT | ||
22 | |||
23 | public: | ||
24 | /////// | ||
25 | SecushareQtView(int argc, char** argv); | ||
26 | ~SecushareQtView() override; | ||
27 | |||
28 | int run() override; | ||
29 | |||
30 | std::shared_ptr<AbstractUserConfigModel> getUserConfigModel() const override | ||
31 | {return mUserConfigModel;} | ||
32 | |||
33 | signals: | ||
34 | //////// | ||
35 | void shutdownRequest(); | ||
36 | void addEgoRequest(const std::string& name); | ||
37 | void addFriendRequst(const IdentityId& nymId); | ||
38 | void sendMessageRequest(const PlaceId& placeId, const std::string& message); | ||
39 | |||
40 | private: | ||
41 | //////// | ||
42 | int mArgc; | ||
43 | char** mArgv; | ||
44 | std::shared_ptr<QtUserConfigModel> mUserConfigModel; | ||
45 | |||
46 | static Util::NotifyPipe shutdownPipe; | ||
47 | QSocketNotifier *sigNotifier; | ||
48 | |||
49 | void catchUnixSignals( | ||
50 | const std::vector<int>& quitSignals, | ||
51 | const std::vector<int>& ignoreSignals = {} | ||
52 | ); | ||
53 | }; | ||
54 | } | ||
55 | |||
56 | #endif | ||
diff --git a/trunk/include/Signal.hpp b/trunk/include/Signal.hpp new file mode 100644 index 0000000..63dc55f --- /dev/null +++ b/trunk/include/Signal.hpp | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <sigc++/sigc++.h> | ||
2 | |||
3 | namespace redthread | ||
4 | { | ||
5 | template | ||
6 | < | ||
7 | class T_return, | ||
8 | class T_arg1 = sigc::nil, | ||
9 | class T_arg2 = sigc::nil, | ||
10 | class T_arg3 = sigc::nil, | ||
11 | class T_arg4 = sigc::nil, | ||
12 | class T_arg5 = sigc::nil, | ||
13 | class T_arg6 = sigc::nil, | ||
14 | class T_arg7 = sigc::nil | ||
15 | > | ||
16 | using SignalT = | ||
17 | sigc::signal< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 >; | ||
18 | } | ||
19 | |||
20 | //#include <boost/signals2.hpp> | ||
21 | // | ||
22 | //namespace redthread | ||
23 | //{ | ||
24 | // template <typename Signature> | ||
25 | // using SignalT = boost::signals2::signal<Signature>; | ||
26 | //} | ||