diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_send.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_send.c | 93 |
1 files changed, 59 insertions, 34 deletions
diff --git a/src/messenger/gnunet-service-messenger_message_send.c b/src/messenger/gnunet-service-messenger_message_send.c index 40ff95cef..5c3f9ecc5 100644 --- a/src/messenger/gnunet-service-messenger_message_send.c +++ b/src/messenger/gnunet-service-messenger_message_send.c | |||
@@ -48,68 +48,86 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, | |||
48 | if (session->prev) | 48 | if (session->prev) |
49 | notify_about_members (notify, session->prev, map, GNUNET_YES); | 49 | notify_about_members (notify, session->prev, map, GNUNET_YES); |
50 | 50 | ||
51 | struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(notify->room); | 51 | struct GNUNET_MESSENGER_MessageStore *message_store = |
52 | get_srv_room_message_store (notify->room); | ||
52 | struct GNUNET_MESSENGER_ListMessage *element; | 53 | struct GNUNET_MESSENGER_ListMessage *element; |
53 | 54 | ||
54 | for (element = session->messages.head; element; element = element->next) | 55 | for (element = session->messages.head; element; element = element->next) |
55 | { | 56 | { |
56 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(map, &(element->hash))) | 57 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (map, |
58 | &(element->hash))) | ||
57 | continue; | 59 | continue; |
58 | 60 | ||
59 | if ((GNUNET_YES == check_permission) && | 61 | if ((GNUNET_YES == check_permission) && |
60 | (GNUNET_YES != check_member_session_history(notify->session, &(element->hash), GNUNET_NO))) | 62 | (GNUNET_YES != check_member_session_history (notify->session, |
63 | &(element->hash), | ||
64 | GNUNET_NO))) | ||
61 | continue; | 65 | continue; |
62 | 66 | ||
63 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(map, &(element->hash), NULL, | 67 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (map, &(element->hash), |
64 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | 68 | NULL, |
65 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Notification of session message could be duplicated!\n"); | 69 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
70 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
71 | "Notification of session message could be duplicated!\n"); | ||
66 | 72 | ||
67 | const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash)); | 73 | const struct GNUNET_MESSENGER_Message *message = get_store_message ( |
74 | message_store, &(element->hash)); | ||
68 | 75 | ||
69 | if ((!message) || (GNUNET_YES == is_peer_message (message))) | 76 | if ((! message) || (GNUNET_YES == is_peer_message (message))) |
70 | continue; | 77 | continue; |
71 | 78 | ||
72 | struct GNUNET_MESSENGER_SenderSession sender; | 79 | struct GNUNET_MESSENGER_SenderSession sender; |
73 | sender.member = session; | 80 | sender.member = session; |
74 | 81 | ||
75 | notify_srv_handle_message (notify->handle, notify->room, &sender, message, &(element->hash)); | 82 | notify_srv_handle_message (notify->handle, notify->room, &sender, message, |
83 | &(element->hash)); | ||
76 | } | 84 | } |
77 | } | 85 | } |
78 | 86 | ||
87 | |||
79 | static int | 88 | static int |
80 | iterate_notify_about_members (void *cls, | 89 | iterate_notify_about_members (void *cls, |
81 | const struct GNUNET_IDENTITY_PublicKey *public_key, | 90 | const struct |
91 | GNUNET_IDENTITY_PublicKey *public_key, | ||
82 | struct GNUNET_MESSENGER_MemberSession *session) | 92 | struct GNUNET_MESSENGER_MemberSession *session) |
83 | { | 93 | { |
84 | struct GNUNET_MESSENGER_MemberNotify *notify = cls; | 94 | struct GNUNET_MESSENGER_MemberNotify *notify = cls; |
85 | 95 | ||
86 | if ((notify->session == session) || (GNUNET_YES == is_member_session_completed(session))) | 96 | if ((notify->session == session) || (GNUNET_YES == |
97 | is_member_session_completed (session))) | ||
87 | return GNUNET_YES; | 98 | return GNUNET_YES; |
88 | 99 | ||
89 | struct GNUNET_CONTAINER_MultiHashMap *map = GNUNET_CONTAINER_multihashmap_create(4, GNUNET_NO); | 100 | struct GNUNET_CONTAINER_MultiHashMap *map = |
101 | GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO); | ||
90 | 102 | ||
91 | notify_about_members (notify, session, map, GNUNET_NO); | 103 | notify_about_members (notify, session, map, GNUNET_NO); |
92 | 104 | ||
93 | GNUNET_CONTAINER_multihashmap_destroy(map); | 105 | GNUNET_CONTAINER_multihashmap_destroy (map); |
94 | return GNUNET_YES; | 106 | return GNUNET_YES; |
95 | } | 107 | } |
96 | 108 | ||
109 | |||
97 | void | 110 | void |
98 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, | 111 | send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, |
99 | struct GNUNET_MESSENGER_SrvHandle *handle, | 112 | struct GNUNET_MESSENGER_SrvHandle *handle, |
100 | const struct GNUNET_MESSENGER_Message *message, | 113 | const struct GNUNET_MESSENGER_Message *message, |
101 | const struct GNUNET_HashCode *hash) | 114 | const struct GNUNET_HashCode *hash) |
102 | { | 115 | { |
103 | set_srv_handle_key(handle, &(message->body.join.key)); | 116 | set_srv_handle_key (handle, &(message->body.join.key)); |
104 | 117 | ||
105 | struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room); | 118 | struct GNUNET_MESSENGER_MemberStore *member_store = |
106 | struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, &(message->header.sender_id)); | 119 | get_srv_room_member_store (room); |
120 | struct GNUNET_MESSENGER_Member *member = add_store_member (member_store, | ||
121 | &(message->header. | ||
122 | sender_id)); | ||
107 | 123 | ||
108 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of (member, message, hash); | 124 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of ( |
125 | member, message, hash); | ||
109 | 126 | ||
110 | if (!session) | 127 | if (! session) |
111 | { | 128 | { |
112 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "A valid session is required to join a room!\n"); | 129 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
130 | "A valid session is required to join a room!\n"); | ||
113 | goto skip_member_notification; | 131 | goto skip_member_notification; |
114 | } | 132 | } |
115 | 133 | ||
@@ -119,54 +137,61 @@ send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, | |||
119 | notify.handle = handle; | 137 | notify.handle = handle; |
120 | notify.session = session; | 138 | notify.session = session; |
121 | 139 | ||
122 | iterate_store_members(get_srv_room_member_store(room), iterate_notify_about_members, ¬ify); | 140 | iterate_store_members (get_srv_room_member_store (room), |
141 | iterate_notify_about_members, ¬ify); | ||
123 | 142 | ||
124 | skip_member_notification: | 143 | skip_member_notification: |
125 | check_srv_room_peer_status(room, NULL); | 144 | check_srv_room_peer_status (room, NULL); |
126 | } | 145 | } |
127 | 146 | ||
147 | |||
128 | void | 148 | void |
129 | send_message_key (struct GNUNET_MESSENGER_SrvRoom *room, | 149 | send_message_key (struct GNUNET_MESSENGER_SrvRoom *room, |
130 | struct GNUNET_MESSENGER_SrvHandle *handle, | 150 | struct GNUNET_MESSENGER_SrvHandle *handle, |
131 | const struct GNUNET_MESSENGER_Message *message, | 151 | const struct GNUNET_MESSENGER_Message *message, |
132 | const struct GNUNET_HashCode *hash) | 152 | const struct GNUNET_HashCode *hash) |
133 | { | 153 | { |
134 | set_srv_handle_key(handle, &(message->body.key.key)); | 154 | set_srv_handle_key (handle, &(message->body.key.key)); |
135 | } | 155 | } |
136 | 156 | ||
157 | |||
137 | void | 158 | void |
138 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, | 159 | send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, |
139 | struct GNUNET_MESSENGER_SrvHandle *handle, | 160 | struct GNUNET_MESSENGER_SrvHandle *handle, |
140 | const struct GNUNET_MESSENGER_Message *message, | 161 | const struct GNUNET_MESSENGER_Message *message, |
141 | const struct GNUNET_HashCode *hash) | 162 | const struct GNUNET_HashCode *hash) |
142 | { | 163 | { |
143 | if (!room->peer_message) | 164 | if (! room->peer_message) |
144 | room->peer_message = GNUNET_new(struct GNUNET_HashCode); | 165 | room->peer_message = GNUNET_new (struct GNUNET_HashCode); |
145 | 166 | ||
146 | GNUNET_memcpy(room->peer_message, hash, sizeof(struct GNUNET_HashCode)); | 167 | GNUNET_memcpy (room->peer_message, hash, sizeof(struct GNUNET_HashCode)); |
147 | } | 168 | } |
148 | 169 | ||
170 | |||
149 | void | 171 | void |
150 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, | 172 | send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, |
151 | struct GNUNET_MESSENGER_SrvHandle *handle, | 173 | struct GNUNET_MESSENGER_SrvHandle *handle, |
152 | const struct GNUNET_MESSENGER_Message *message, | 174 | const struct GNUNET_MESSENGER_Message *message, |
153 | const struct GNUNET_HashCode *hash) | 175 | const struct GNUNET_HashCode *hash) |
154 | { | 176 | { |
155 | change_srv_handle_member_id (handle, get_srv_room_key(room), &(message->body.id.id)); | 177 | change_srv_handle_member_id (handle, get_srv_room_key (room), |
178 | &(message->body.id.id)); | ||
156 | } | 179 | } |
157 | 180 | ||
181 | |||
158 | void | 182 | void |
159 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, | 183 | send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, |
160 | struct GNUNET_MESSENGER_SrvHandle *handle, | 184 | struct GNUNET_MESSENGER_SrvHandle *handle, |
161 | const struct GNUNET_MESSENGER_Message *message, | 185 | const struct GNUNET_MESSENGER_Message *message, |
162 | const struct GNUNET_HashCode *hash) | 186 | const struct GNUNET_HashCode *hash) |
163 | { | 187 | { |
164 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room); | 188 | struct GNUNET_MESSENGER_OperationStore *operation_store = |
165 | 189 | get_srv_room_operation_store (room); | |
166 | use_store_operation( | 190 | |
167 | operation_store, | 191 | use_store_operation ( |
168 | &(message->body.request.hash), | 192 | operation_store, |
169 | GNUNET_MESSENGER_OP_REQUEST, | 193 | &(message->body.request.hash), |
170 | GNUNET_MESSENGER_REQUEST_DELAY | 194 | GNUNET_MESSENGER_OP_REQUEST, |
171 | ); | 195 | GNUNET_MESSENGER_REQUEST_DELAY |
196 | ); | ||
172 | } | 197 | } |