1 // This file is part of BOINC. 2 // http://boinc.berkeley.edu 3 // Copyright (C) 2008 University of California 4 // 5 // BOINC is free software; you can redistribute it and/or modify it 6 // under the terms of the GNU Lesser General Public License 7 // as published by the Free Software Foundation, 8 // either version 3 of the License, or (at your option) any later version. 9 // 10 // BOINC is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 // See the GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 17 18 #ifndef BOINC_CLIENT_MSGS_H 19 #define BOINC_CLIENT_MSGS_H 20 21 #include <algorithm> 22 #include <deque> 23 #include <string> 24 #include <string.h> 25 26 #include "client_types.h" 27 #include "common_defs.h" 28 #include "log_flags.h" 29 30 // stores a message in memory, where it can be retrieved via RPC 31 32 struct MESSAGE_DESC { 33 char project_name[256]; 34 int priority; 35 int timestamp; 36 int seqno; 37 std::string message; 38 }; 39 40 #define MAX_SAVED_MESSAGES 2000 41 42 // a cache of MAX_SAVED_MESSAGES most recent messages, 43 // stored in newest-first order 44 // 45 struct MESSAGE_DESCS { 46 std::deque<MESSAGE_DESC*> msgs; 47 void insert(PROJ_AM *p, int priority, int now, char* msg); 48 void write(int seqno, class MIOFILE&, bool translatable); 49 int highest_seqno(); 50 void cleanup(); 51 }; 52 53 extern MESSAGE_DESCS message_descs; 54 55 // the __attribute((format...)) tags are GCC extensions that let the compiler 56 // do like-checking on printf-like arguments 57 // 58 #if !defined(__GNUC__) && !defined(__attribute__) 59 #define __attribute__(x) /*nothing*/ 60 #endif 61 62 // Show a message, preceded by timestamp and project name 63 64 extern void msg_printf(PROJ_AM *p, int priority, const char *fmt, ...) 65 __attribute__ ((format (printf, 3, 4))) 66 ; 67 68 // Show a MSG_USER_ALERT message (i.e. will be shown as a notice) 69 // Additional info: 70 // is_html: true if message body contains HTML tags 71 // link: URL for "more..." link 72 // 73 extern void msg_printf_notice(PROJ_AM *p, bool is_html, const char* link, const char *fmt, ...) 74 __attribute__ ((format (printf, 4, 5))) 75 ; 76 77 #define _(x) "_(\"" x "\")" 78 79 extern std::string app_list_string(PROJECT*); 80 81 #endif 82