6 * Copyright (C) 2010-2016 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()
41 #elif !PURPLE_VERSION_CHECK(2,6,0) && !PURPLE_VERSION_CHECK(3,0,0)
42 #define SIPE_PURPLE_DEBUG_IS_ENABLED purple_debug_is_enabled()
43 #define SIPE_PURPLE_DEBUG_IS_UNSAFE purple_debug_is_enabled()
46 * The same problem happens when a client uses PurpleDebugUiOps->debug()
47 * to redirect it to stderr, e.g. bitlbee. Such a client will not call
48 * purple_debug_set_enabled(TRUE). Check also the other flags that were
49 * introduced in the 2.6.x API.
51 #define SIPE_PURPLE_DEBUG_IS_ENABLED (purple_debug_is_enabled() || \
52 purple_debug_is_verbose() || \
53 purple_debug_is_unsafe())
54 #define SIPE_PURPLE_DEBUG_IS_UNSAFE purple_debug_is_unsafe()
57 void sipe_backend_debug_literal(sipe_debug_level level
,
60 if ((level
< SIPE_DEBUG_LEVEL_LOWEST
) || SIPE_PURPLE_DEBUG_IS_ENABLED
) {
62 /* purple_debug doesn't have a vprintf-like API call :-( */
64 case SIPE_LOG_LEVEL_INFO
:
65 case SIPE_DEBUG_LEVEL_INFO
:
66 purple_debug_info("sipe", "%s\n", msg
);
68 case SIPE_LOG_LEVEL_WARNING
:
69 case SIPE_DEBUG_LEVEL_WARNING
:
70 purple_debug_warning("sipe", "%s\n", msg
);
72 case SIPE_LOG_LEVEL_ERROR
:
73 case SIPE_DEBUG_LEVEL_ERROR
:
74 purple_debug_error("sipe", "%s\n", msg
);
80 void sipe_backend_debug(sipe_debug_level level
,
88 if ((level
< SIPE_DEBUG_LEVEL_LOWEST
) || SIPE_PURPLE_DEBUG_IS_ENABLED
) {
90 /* purple_debug doesn't have a vprintf-like API call :-( */
91 gchar
*msg
= g_strdup_vprintf(format
, ap
);
92 sipe_backend_debug_literal(level
, msg
);
99 gboolean
sipe_backend_debug_enabled(void)
101 return SIPE_PURPLE_DEBUG_IS_UNSAFE
;