~dylanmccall/ubuntu/oneiric/network-manager-applet/lp852961-disable-autostart-for-gnome-shell

« back to all changes in this revision

Viewing changes to src/nm-utils.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2007-06-15 12:46:22 UTC
  • Revision ID: james.westby@ubuntu.com-20070615124622-01cyrnf0uxxun4lz
Tags: upstream-0.6.5
ImportĀ upstreamĀ versionĀ 0.6.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* NetworkManager -- Network link manager
 
2
 *
 
3
 * Ray Strode <rstrode@redhat.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program 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.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 *
 
19
 * (C) Copyright 2005 Red Hat, Inc.
 
20
 */
 
21
 
 
22
#ifndef NM_UTILS_H
 
23
#define NM_UTILS_H
 
24
 
 
25
#include <glib.h>
 
26
#include <execinfo.h>
 
27
#include <dbus/dbus.h>
 
28
 
 
29
#define nm_print_backtrace()                                            \
 
30
G_STMT_START                                                            \
 
31
{                                                                       \
 
32
        void *_call_stack[512];                                         \
 
33
        int  _call_stack_size;                                          \
 
34
        char **_symbols;                                                \
 
35
        _call_stack_size = backtrace (_call_stack,                      \
 
36
                                      G_N_ELEMENTS (_call_stack));      \
 
37
        _symbols = backtrace_symbols (_call_stack, _call_stack_size);   \
 
38
        if (_symbols != NULL)                                           \
 
39
        {                                                               \
 
40
                int _i;                                                 \
 
41
                _i = 0;                                                 \
 
42
                g_critical ("traceback:\n");                            \
 
43
                while (_i < _call_stack_size)                           \
 
44
                {                                                       \
 
45
                        g_critical ("\t%s\n", _symbols[_i]);            \
 
46
                        _i++;                                           \
 
47
                }                                                       \
 
48
                free (_symbols);                                        \
 
49
        }                                                               \
 
50
}                                                                       \
 
51
G_STMT_END
 
52
 
 
53
#define nm_get_timestamp(timestamp)                                     \
 
54
G_STMT_START                                                            \
 
55
{                                                                       \
 
56
        GTimeVal _tv;                                                   \
 
57
        g_get_current_time (&_tv);                                      \
 
58
        *timestamp = (_tv.tv_sec * (1.0 * G_USEC_PER_SEC) +             \
 
59
                      _tv.tv_usec) / G_USEC_PER_SEC;                    \
 
60
}                                                                       \
 
61
G_STMT_END
 
62
 
 
63
#define nm_info(fmt, args...)                                           \
 
64
G_STMT_START                                                            \
 
65
{                                                                       \
 
66
        g_message ("<info>  " fmt "\n", ##args);                        \
 
67
} G_STMT_END
 
68
 
 
69
#define nm_info_str(fmt_str, args...)                                           \
 
70
G_STMT_START                                                            \
 
71
{                                                                       \
 
72
        g_message ("<info>  %s\n", fmt_str, ##args);                    \
 
73
} G_STMT_END
 
74
 
 
75
#define nm_debug(fmt, args...)                                          \
 
76
G_STMT_START                                                            \
 
77
{                                                                       \
 
78
        gdouble _timestamp;                                             \
 
79
        nm_get_timestamp (&_timestamp);                                 \
 
80
        g_debug ("<debug> [%f] %s(): " fmt "\n", _timestamp,    \
 
81
                 G_STRFUNC, ##args);                            \
 
82
} G_STMT_END
 
83
 
 
84
#define nm_debug_str(fmt_str, args...)                                          \
 
85
G_STMT_START                                                            \
 
86
{                                                                       \
 
87
        gdouble _timestamp;                                             \
 
88
        nm_get_timestamp (&_timestamp);                                 \
 
89
        g_debug ("<debug> [%f] %s(): %s\n", _timestamp, \
 
90
                 G_STRFUNC, fmt_str, ##args);                           \
 
91
} G_STMT_END
 
92
 
 
93
#define nm_warning(fmt, args...)                                        \
 
94
G_STMT_START                                                            \
 
95
{                                                                       \
 
96
        g_warning ("<WARN>  %s(): " fmt "\n",                   \
 
97
                   G_STRFUNC, ##args);                  \
 
98
} G_STMT_END
 
99
 
 
100
#define nm_warning_str(fmt_str, args...)                                        \
 
101
G_STMT_START                                                            \
 
102
{                                                                       \
 
103
        g_warning ("<WARN>  %s(): %s\n",                        \
 
104
                   G_STRFUNC, fmt_str, ##args);                 \
 
105
} G_STMT_END
 
106
 
 
107
#define nm_error(fmt, args...)                                          \
 
108
G_STMT_START                                                            \
 
109
{                                                                       \
 
110
        gdouble _timestamp;                                             \
 
111
        nm_get_timestamp (&_timestamp);                                 \
 
112
        g_critical ("<ERROR>\t[%f] %s (): " fmt "\n", _timestamp,       \
 
113
                    G_STRFUNC, ##args);                 \
 
114
        nm_print_backtrace ();                                          \
 
115
        G_BREAKPOINT ();                                                \
 
116
} G_STMT_END
 
117
 
 
118
#define nm_error_str(fmt_str, args...)                                          \
 
119
G_STMT_START                                                            \
 
120
{                                                                       \
 
121
        gdouble _timestamp;                                             \
 
122
        nm_get_timestamp (&_timestamp);                                 \
 
123
        g_critical ("<ERROR>\t[%f] %s (): %s\n", _timestamp,    \
 
124
                    G_STRFUNC, fmt_str, ##args);                        \
 
125
        nm_print_backtrace ();                                          \
 
126
        G_BREAKPOINT ();                                                \
 
127
} G_STMT_END
 
128
 
 
129
gchar *nm_dbus_escape_object_path (const gchar *utf8_string);
 
130
gchar *nm_dbus_unescape_object_path (const gchar *object_path);
 
131
 
 
132
char *nm_utils_essid_to_utf8 (const char *orig_essid);
 
133
 
 
134
/* #define DBUS_PENDING_CALL_DEBUG */
 
135
 
 
136
DBusPendingCall * nm_dbus_send_with_callback (DBusConnection *connection,
 
137
                                              DBusMessage *msg, 
 
138
                                              DBusPendingCallNotifyFunction func,
 
139
                                              gpointer data,
 
140
                                              DBusFreeFunction free_func,
 
141
                                              const char *caller);
 
142
void nm_dbus_send_with_callback_replied (DBusPendingCall *pcall,
 
143
                                         const char *caller);
 
144
 
 
145
#endif /* NM_UTILS_H */