1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */ 2 /* Balsa E-Mail Client 3 * Copyright (C) 1997-2013 Stuart Parmenter and others, 4 * See the file AUTHORS for a list. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * 02111-1307, USA. 20 */ 21 22 #ifndef __THREADS_H__ 23 #define __THREADS_H__ 24 25 #include <unistd.h> 26 #include <pthread.h> 27 28 /* allocated in main.c */ 29 extern pthread_mutex_t checking_mail_lock; 30 31 /* define thread globals */ 32 extern pthread_t get_mail_thread; 33 extern int checking_mail; 34 extern int mail_thread_pipes[2]; 35 extern GIOChannel *mail_thread_msg_send; 36 extern GIOChannel *mail_thread_msg_receive; 37 extern GIOChannel *send_thread_msg_send; 38 extern GIOChannel *send_thread_msg_receive; 39 40 extern GtkWidget *send_progress_message; 41 extern GtkWidget *send_dialog; 42 extern GtkWidget *send_dialog_bar; 43 44 typedef struct { 45 LibBalsaMailboxNotify message_type; 46 char message_string[160]; 47 LibBalsaMailbox *mailbox; 48 int num_bytes, tot_bytes; 49 } MailThreadMessage; 50 51 /* 52 * Macro to send message: 53 * message is MailThreadMessage *message 54 * type is one of the defined message types below 55 * string is string to send 56 */ 57 58 #define MSGMAILTHREAD( message, type, mbox, string, num, tot) \ 59 message = g_new(MailThreadMessage, 1); \ 60 message->message_type = type; \ 61 message->mailbox = mbox; \ 62 strncpy( message->message_string, string, sizeof(message->message_string)); \ 63 message->message_string[sizeof(message->message_string)-1]='\0';\ 64 message->num_bytes=num;\ 65 message->tot_bytes=tot;\ 66 if (write( mail_thread_pipes[1], (void *) &message, sizeof(void *) ) \ 67 != sizeof(void *)) \ 68 g_warning("pipe error"); 69 70 #endif /* __THREADS_H__ */ 71