| | 149 | typedef struct { |
|---|
| | 150 | TnyAccount *account; |
|---|
| | 151 | TnyStream *stream; |
|---|
| | 152 | TnySendQueue *send_queue; |
|---|
| | 153 | TnyMsg *msg; |
|---|
| | 154 | TnyList *attachments; |
|---|
| | 155 | } CreateAndSendMsgInfo; |
|---|
| | 156 | |
|---|
| | 157 | static gpointer |
|---|
| | 158 | create_and_send_msg_thread (gpointer user_data) |
|---|
| | 159 | { |
|---|
| | 160 | CreateAndSendMsgInfo *info = (CreateAndSendMsgInfo *) user_data; |
|---|
| | 161 | |
|---|
| | 162 | if (info->attachments && tny_list_get_length (info->attachments) > 0) { |
|---|
| | 163 | TnyIterator *iter = tny_list_create_iterator (info->attachments); |
|---|
| | 164 | TnyMimePart *msg_part = tny_camel_mime_part_new (); |
|---|
| | 165 | |
|---|
| | 166 | tny_mime_part_construct_from_stream (msg_part, info->stream, "text/plain"); |
|---|
| | 167 | tny_mime_part_add_part (TNY_MIME_PART (info->msg), msg_part); |
|---|
| | 168 | g_object_unref (msg_part); |
|---|
| | 169 | |
|---|
| | 170 | while (!tny_iterator_is_done (iter)) { |
|---|
| | 171 | TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter)); |
|---|
| | 172 | tny_mime_part_add_part (TNY_MIME_PART (info->msg), part); |
|---|
| | 173 | g_object_unref (part); |
|---|
| | 174 | tny_iterator_next (iter); |
|---|
| | 175 | } |
|---|
| | 176 | g_object_unref (iter); |
|---|
| | 177 | } else |
|---|
| | 178 | tny_mime_part_construct_from_stream (TNY_MIME_PART (info->msg), info->stream, "text/plain"); |
|---|
| | 179 | |
|---|
| | 180 | tny_send_queue_add (info->send_queue, info->msg, NULL); |
|---|
| | 181 | |
|---|
| | 182 | |
|---|
| | 183 | if (info->attachments) |
|---|
| | 184 | g_object_unref (info->attachments); |
|---|
| | 185 | g_object_unref (info->send_queue); |
|---|
| | 186 | g_object_unref (info->msg); |
|---|
| | 187 | g_object_unref (info->stream); |
|---|
| | 188 | g_object_unref (info->account); |
|---|
| | 189 | |
|---|
| | 190 | g_slice_free (CreateAndSendMsgInfo, info); |
|---|
| | 191 | |
|---|
| | 192 | return NULL; |
|---|
| | 193 | } |
|---|
| | 194 | |
|---|
| 186 | | if (tny_list_get_length (priv->attachments) > 0) { |
|---|
| 187 | | TnyIterator *iter = tny_list_create_iterator (priv->attachments); |
|---|
| 188 | | TnyMimePart *msg_part = tny_camel_mime_part_new (); |
|---|
| 189 | | |
|---|
| 190 | | tny_mime_part_construct_from_stream (msg_part, stream, "text/plain"); |
|---|
| 191 | | tny_mime_part_add_part (TNY_MIME_PART (msg), msg_part); |
|---|
| 192 | | g_object_unref (msg_part); |
|---|
| 193 | | |
|---|
| 194 | | while (!tny_iterator_is_done (iter)) { |
|---|
| 195 | | TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter)); |
|---|
| 196 | | tny_mime_part_add_part (TNY_MIME_PART (msg), part); |
|---|
| 197 | | g_object_unref (part); |
|---|
| 198 | | tny_iterator_next (iter); |
|---|
| 199 | | } |
|---|
| 200 | | g_object_unref (iter); |
|---|
| 201 | | } else |
|---|
| 202 | | tny_mime_part_construct_from_stream (TNY_MIME_PART (msg), stream, "text/plain"); |
|---|
| | 233 | if (priv->attachments) |
|---|
| | 234 | info->attachments = tny_list_copy (priv->attachments); |
|---|
| | 235 | else |
|---|
| | 236 | info->attachments = NULL; |
|---|
| | 237 | info->send_queue = g_object_ref (send_queue); |
|---|
| | 238 | info->msg = g_object_ref (msg); |
|---|
| | 239 | info->stream = g_object_ref (stream); |
|---|
| | 240 | info->account = g_object_ref (account); |
|---|
| | 241 | |
|---|
| | 242 | g_thread_create (create_and_send_msg_thread, info, FALSE, NULL); |
|---|