6 * Copyright (C) 2010-2017 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "sipe-backend.h"
33 * libpurple uses g_print() and PurpleDebugUiOps->debug() when
34 * purple_debug_is_enabled() returns TRUE. Both are redirected
35 * by Adium to AILog(). To avoid duplicated log lines Adium
36 * therefore never calls purple_debug_set_enabled(TRUE).
38 gboolean
AIDebugLoggingIsEnabled(void);
39 #define SIPE_PURPLE_DEBUG_IS_ENABLED AIDebugLoggingIsEnabled()
40 #define SIPE_PURPLE_DEBUG_IS_UNSAFE AIDebugLoggingIsEnabled()
43 * The same problem happens when a client uses PurpleDebugUiOps->debug()
44 * to redirect it to stderr, e.g. bitlbee. Such a client will not call
45 * purple_debug_set_enabled(TRUE). Check also the other flags that were
46 * introduced in the 2.6.x API.
48 #define SIPE_PURPLE_DEBUG_IS_ENABLED (purple_debug_is_enabled() || \
49 purple_debug_is_verbose() || \
50 purple_debug_is_unsafe())
51 #define SIPE_PURPLE_DEBUG_IS_UNSAFE purple_debug_is_unsafe()
54 void sipe_backend_debug_literal(sipe_debug_level level
,
57 if ((level
< SIPE_DEBUG_LEVEL_LOWEST
) || SIPE_PURPLE_DEBUG_IS_ENABLED
) {
59 /* purple_debug doesn't have a vprintf-like API call :-( */
61 case SIPE_LOG_LEVEL_INFO
:
62 case SIPE_DEBUG_LEVEL_INFO
:
63 purple_debug_info("sipe", "%s\n", msg
);
65 case SIPE_LOG_LEVEL_WARNING
:
66 case SIPE_DEBUG_LEVEL_WARNING
:
67 purple_debug_warning("sipe", "%s\n", msg
);
69 case SIPE_LOG_LEVEL_ERROR
:
70 case SIPE_DEBUG_LEVEL_ERROR
:
71 purple_debug_error("sipe", "%s\n", msg
);
77 void sipe_backend_debug(sipe_debug_level level
,
85 if ((level
< SIPE_DEBUG_LEVEL_LOWEST
) || SIPE_PURPLE_DEBUG_IS_ENABLED
) {
87 /* purple_debug doesn't have a vprintf-like API call :-( */
88 gchar
*msg
= g_strdup_vprintf(format
, ap
);
89 sipe_backend_debug_literal(level
, msg
);
96 gboolean
sipe_backend_debug_enabled(void)
98 return SIPE_PURPLE_DEBUG_IS_UNSAFE
;