appshare: process incoming invite
[siplcs.git] / src / purple / purple-debug.c
blob0075ee43318784d2c967961d58775371f19b5733
1 /**
2 * @file purple-debug.c
4 * pidgin-sipe
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
23 #include <stdarg.h>
25 #include "glib.h"
26 #include "debug.h"
27 #include "version.h"
29 #include "sipe-backend.h"
31 #ifdef ADIUM
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()
44 #else
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()
55 #endif
57 void sipe_backend_debug_literal(sipe_debug_level level,
58 const gchar *msg)
60 if ((level < SIPE_DEBUG_LEVEL_LOWEST) || SIPE_PURPLE_DEBUG_IS_ENABLED) {
62 /* purple_debug doesn't have a vprintf-like API call :-( */
63 switch (level) {
64 case SIPE_LOG_LEVEL_INFO:
65 case SIPE_DEBUG_LEVEL_INFO:
66 purple_debug_info("sipe", "%s\n", msg);
67 break;
68 case SIPE_LOG_LEVEL_WARNING:
69 case SIPE_DEBUG_LEVEL_WARNING:
70 purple_debug_warning("sipe", "%s\n", msg);
71 break;
72 case SIPE_LOG_LEVEL_ERROR:
73 case SIPE_DEBUG_LEVEL_ERROR:
74 purple_debug_error("sipe", "%s\n", msg);
75 break;
80 void sipe_backend_debug(sipe_debug_level level,
81 const gchar *format,
82 ...)
84 va_list ap;
86 va_start(ap, format);
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);
93 g_free(msg);
96 va_end(ap);
99 gboolean sipe_backend_debug_enabled(void)
101 return SIPE_PURPLE_DEBUG_IS_UNSAFE;
105 Local Variables:
106 mode: c
107 c-file-style: "bsd"
108 indent-tabs-mode: t
109 tab-width: 8
110 End: