index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000004.html
dbus
dbus-object-tree.c
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-object-tree.c  DBusObjectTree (internals of DBusConnection)
00003
*
00004
* Copyright (C) 2003, 2005  Red Hat Inc.
00005
*
00006
* Licensed under the Academic Free License version 2.1
00007
*
00008
* This program is free software; you can redistribute it and/or modify
00009
* it under the terms of the GNU General Public License as published by
00010
* the Free Software Foundation; either version 2 of the License, or
00011
* (at your option) any later version.
00012
*
00013
* This program is distributed in the hope that it will be useful,
00014
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00015
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016
* GNU General Public License for more details.
00017
*
00018
* You should have received a copy of the GNU General Public License
00019
* along with this program; if not, write to the Free Software
00020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021
*
00022
*/
00023
#include "dbus-object-tree.h"
00024
#include "dbus-connection-internal.h"
00025
#include "dbus-internals.h"
00026
#include "dbus-hash.h"
00027
#include "dbus-protocol.h"
00028
#include "dbus-string.h"
00029
#include <string.h>
00030
#include <stdlib.h>
00031
group__DBusObjectTree.html#ga0
00044
typedef
struct
structDBusObjectSubtree.html
DBusObjectSubtree
DBusObjectSubtree;
00045
00046
static
DBusObjectSubtree* _dbus_object_subtree_new   (
const
char
*
structDBusObjectSubtree.html#o9
name
,
00047
const
structDBusObjectPathVTable.html
DBusObjectPathVTable
*vtable,
00048
void
*
structDBusObjectSubtree.html#o4
user_data
);
00049
static
DBusObjectSubtree* _dbus_object_subtree_ref   (DBusObjectSubtree           *subtree);
00050
static
void
_dbus_object_subtree_unref (DBusObjectSubtree           *subtree);
00051
structDBusObjectTree.html
00055
struct
structDBusObjectTree.html
DBusObjectTree
00056 {
structDBusObjectTree.html#o0
00057
int
structDBusObjectTree.html#o0
refcount
;
structDBusObjectTree.html#o1
00058
structDBusConnection.html
DBusConnection
*
structDBusObjectTree.html#o1
connection
;
structDBusObjectTree.html#o2
00060
DBusObjectSubtree  *
structDBusObjectTree.html#o2
root
;
00061 };
00062
structDBusObjectSubtree.html
00068
struct
DBusObjectSubtree
00069 {
structDBusObjectSubtree.html#o0
00070
structDBusAtomic.html
DBusAtomic
structDBusObjectSubtree.html#o0
refcount
;
structDBusObjectSubtree.html#o1
00071
DBusObjectSubtree                 *
structDBusObjectSubtree.html#o1
parent
;
structDBusObjectSubtree.html#o2
00072
DBusObjectPathUnregisterFunction
structDBusObjectSubtree.html#o2
unregister_function
;
structDBusObjectSubtree.html#o3
00073
DBusObjectPathMessageFunction
structDBusObjectSubtree.html#o3
message_function
;
structDBusObjectSubtree.html#o4
00074
void
*
structDBusObjectSubtree.html#o4
user_data
;
structDBusObjectSubtree.html#o5
00075
DBusObjectSubtree                **
structDBusObjectSubtree.html#o5
subtrees
;
structDBusObjectSubtree.html#o6
00076
int
structDBusObjectSubtree.html#o6
n_subtrees
;
structDBusObjectSubtree.html#o7
00077
unsigned
int
structDBusObjectSubtree.html#o7
subtrees_sorted
: 1;
structDBusObjectSubtree.html#o8
00078
unsigned
int
structDBusObjectSubtree.html#o8
invoke_as_fallback
: 1;
structDBusObjectSubtree.html#o9
00079
char
structDBusObjectSubtree.html#o9
name
[1];
00080 };
00081
00089
structDBusObjectTree.html
DBusObjectTree
*
group__DBusObjectTree.html#ga4
00090
group__DBusObjectTree.html#ga4
_dbus_object_tree_new
(
structDBusConnection.html
DBusConnection
*connection)
00091 {
00092
structDBusObjectTree.html
DBusObjectTree
*tree;
00093
00094
/* the connection passed in here isn't fully constructed,
00095
* so don't do anything more than store a pointer to
00096
* it
00097
*/
00098
00099   tree =
group__DBusMemory.html#ga7
dbus_new0
(
structDBusObjectTree.html
DBusObjectTree
, 1);
00100
if
(tree ==
group__DBusMacros.html#ga4
NULL
)
00101
goto
oom;
00102
00103   tree->
structDBusObjectTree.html#o0
refcount
= 1;
00104   tree->
structDBusObjectTree.html#o1
connection
= connection;
00105   tree->
structDBusObjectTree.html#o2
root
= _dbus_object_subtree_new (
"/"
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00106
if
(tree->
structDBusObjectTree.html#o2
root
==
group__DBusMacros.html#ga4
NULL
)
00107
goto
oom;
00108   tree->
structDBusObjectTree.html#o2
root
->
structDBusObjectSubtree.html#o8
invoke_as_fallback
=
group__DBusMacros.html#ga2
TRUE
;
00109
00110
return
tree;
00111
00112  oom:
00113
if
(tree)
00114     {
00115
group__DBusMemory.html#ga3
dbus_free
(tree);
00116     }
00117
00118
return
group__DBusMacros.html#ga4
NULL
;
00119 }
00120
00126
structDBusObjectTree.html
DBusObjectTree
*
group__DBusObjectTree.html#ga5
00127
group__DBusObjectTree.html#ga5
_dbus_object_tree_ref
(
structDBusObjectTree.html
DBusObjectTree
*tree)
00128 {
00129
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree->
structDBusObjectTree.html#o0
refcount
> 0);
00130
00131   tree->
structDBusObjectTree.html#o0
refcount
+= 1;
00132
00133
return
tree;
00134 }
00135
00140
void
group__DBusObjectTree.html#ga6
00141
group__DBusObjectTree.html#ga6
_dbus_object_tree_unref
(
structDBusObjectTree.html
DBusObjectTree
*tree)
00142 {
00143
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree->
structDBusObjectTree.html#o0
refcount
> 0);
00144
00145   tree->
structDBusObjectTree.html#o0
refcount
-= 1;
00146
00147
if
(tree->
structDBusObjectTree.html#o0
refcount
== 0)
00148     {
00149
group__DBusObjectTree.html#ga18
_dbus_object_tree_free_all_unlocked
(tree);
00150
00151
group__DBusMemory.html#ga3
dbus_free
(tree);
00152     }
00153 }
00154
00155
static
int
00156 subtree_cmp (DBusObjectSubtree *subtree_a,
00157              DBusObjectSubtree *subtree_b)
00158 {
00159
return
strcmp (subtree_a->
structDBusObjectSubtree.html#o9
name
, subtree_b->
structDBusObjectSubtree.html#o9
name
);
00160 }
00161
00162
static
int
00163 subtree_qsort_cmp (
const
void
*a,
00164
const
void
*b)
00165 {
00166   DBusObjectSubtree **subtree_a_p = (
void
*) a;
00167   DBusObjectSubtree **subtree_b_p = (
void
*) b;
00168
00169
return
subtree_cmp (*subtree_a_p, *subtree_b_p);
00170 }
00171
00172
static
void
00173 ensure_sorted (DBusObjectSubtree *subtree)
00174 {
00175
if
(subtree->
structDBusObjectSubtree.html#o5
subtrees
&& !subtree->
structDBusObjectSubtree.html#o7
subtrees_sorted
)
00176     {
00177       qsort (subtree->
structDBusObjectSubtree.html#o5
subtrees
,
00178              subtree->
structDBusObjectSubtree.html#o6
n_subtrees
,
00179              sizeof (DBusObjectSubtree*),
00180              subtree_qsort_cmp);
00181       subtree->
structDBusObjectSubtree.html#o7
subtrees_sorted
=
group__DBusMacros.html#ga2
TRUE
;
00182     }
00183 }
00184
group__DBusObjectTree.html#ga26
00188
#define VERBOSE_FIND 0
00189
00190
static
DBusObjectSubtree*
00191 find_subtree_recurse (DBusObjectSubtree  *subtree,
00192
const
char
**path,
00193
group__DBusTypes.html#ga2
dbus_bool_t
create_if_not_found,
00194
int
*index_in_parent,
00195
group__DBusTypes.html#ga2
dbus_bool_t
*exact_match)
00196 {
00197
int
i;
00198
group__DBusTypes.html#ga2
dbus_bool_t
return_deepest_match;
00199
00200   return_deepest_match = exact_match !=
group__DBusMacros.html#ga4
NULL
;
00201
00202
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!(return_deepest_match && create_if_not_found));
00203
00204
if
(path[0] ==
group__DBusMacros.html#ga4
NULL
)
00205     {
00206
#if VERBOSE_FIND
00207
_dbus_verbose (
"  path exhausted, returning %s\n"
,
00208                      subtree->
structDBusObjectSubtree.html#o9
name
);
00209
#endif
00210
if
(exact_match !=
group__DBusMacros.html#ga4
NULL
)
00211         *exact_match =
group__DBusMacros.html#ga2
TRUE
;
00212
return
subtree;
00213     }
00214
00215
#if VERBOSE_FIND
00216
_dbus_verbose (
"  searching children of %s for %s\n"
,
00217                  subtree->
structDBusObjectSubtree.html#o9
name
, path[0]);
00218
#endif
00219
00220   ensure_sorted (subtree);
00221
00222
/* FIXME we should do a binary search here instead
00223
* of O(n)
00224
*/
00225
00226   i = 0;
00227
while
(i < subtree->n_subtrees)
00228     {
00229
int
v;
00230
00231       v = strcmp (path[0], subtree->
structDBusObjectSubtree.html#o5
subtrees
[i]->
structDBusObjectSubtree.html#o9
name
);
00232
00233
#if VERBOSE_FIND
00234
_dbus_verbose (
"  %s cmp %s = %d\n"
,
00235                      path[0], subtree->
structDBusObjectSubtree.html#o5
subtrees
[i]->
structDBusObjectSubtree.html#o9
name
,
00236                      v);
00237
#endif
00238
00239
if
(v == 0)
00240         {
00241
if
(index_in_parent)
00242             {
00243
#if VERBOSE_FIND
00244
_dbus_verbose (
"  storing parent index %d\n"
, i);
00245
#endif
00246
*index_in_parent = i;
00247             }
00248
00249
if
(return_deepest_match)
00250             {
00251               DBusObjectSubtree *next;
00252
00253               next = find_subtree_recurse (subtree->
structDBusObjectSubtree.html#o5
subtrees
[i],
00254                                            &path[1], create_if_not_found,
00255                                            index_in_parent, exact_match);
00256
if
(next ==
group__DBusMacros.html#ga4
NULL
&&
00257                   subtree->
structDBusObjectSubtree.html#o8
invoke_as_fallback
)
00258                 {
00259
#if VERBOSE_FIND
00260
_dbus_verbose (
"  no deeper match found, returning %s\n"
,
00261                                  subtree->
structDBusObjectSubtree.html#o9
name
);
00262
#endif
00263
if
(exact_match !=
group__DBusMacros.html#ga4
NULL
)
00264                     *exact_match =
group__DBusMacros.html#ga3
FALSE
;
00265
return
subtree;
00266                 }
00267
else
00268
return
next;
00269             }
00270
else
00271
return
find_subtree_recurse (subtree->
structDBusObjectSubtree.html#o5
subtrees
[i],
00272                                          &path[1], create_if_not_found,
00273                                          index_in_parent, exact_match);
00274         }
00275
else
if
(v < 0)
00276         {
00277
goto
not_found;
00278         }
00279
00280       ++i;
00281     }
00282
00283  not_found:
00284
#if VERBOSE_FIND
00285
_dbus_verbose (
"  no match found, current tree %s, create_if_not_found = %d\n"
,
00286                  subtree->
structDBusObjectSubtree.html#o9
name
, create_if_not_found);
00287
#endif
00288
00289
if
(create_if_not_found)
00290     {
00291       DBusObjectSubtree* child;
00292       DBusObjectSubtree **new_subtrees;
00293
int
new_n_subtrees;
00294
00295
#if VERBOSE_FIND
00296
_dbus_verbose (
"  creating subtree %s\n"
,
00297                      path[0]);
00298
#endif
00299
00300       child = _dbus_object_subtree_new (path[0],
00301
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00302
if
(child ==
group__DBusMacros.html#ga4
NULL
)
00303
return
group__DBusMacros.html#ga4
NULL
;
00304
00305
/* FIXME we should do the "double alloc each time" standard thing */
00306       new_n_subtrees = subtree->
structDBusObjectSubtree.html#o6
n_subtrees
+ 1;
00307       new_subtrees =
group__DBusMemory.html#ga2
dbus_realloc
(subtree->
structDBusObjectSubtree.html#o5
subtrees
,
00308                                    new_n_subtrees * sizeof (DBusObjectSubtree*));
00309
if
(new_subtrees ==
group__DBusMacros.html#ga4
NULL
)
00310         {
00311           child->
structDBusObjectSubtree.html#o2
unregister_function
=
group__DBusMacros.html#ga4
NULL
;
00312           child->
structDBusObjectSubtree.html#o3
message_function
=
group__DBusMacros.html#ga4
NULL
;
00313           _dbus_object_subtree_unref (child);
00314
return
group__DBusMacros.html#ga4
NULL
;
00315         }
00316
00317       new_subtrees[subtree->
structDBusObjectSubtree.html#o6
n_subtrees
] = child;
00318
if
(index_in_parent)
00319         *index_in_parent = subtree->
structDBusObjectSubtree.html#o6
n_subtrees
;
00320       subtree->
structDBusObjectSubtree.html#o7
subtrees_sorted
=
group__DBusMacros.html#ga3
FALSE
;
00321       subtree->
structDBusObjectSubtree.html#o6
n_subtrees
= new_n_subtrees;
00322       subtree->
structDBusObjectSubtree.html#o5
subtrees
= new_subtrees;
00323
00324       child->
structDBusObjectSubtree.html#o1
parent
= subtree;
00325
00326
return
find_subtree_recurse (child,
00327                                    &path[1], create_if_not_found,
00328                                    index_in_parent, exact_match);
00329     }
00330
else
00331     {
00332
if
(exact_match !=
group__DBusMacros.html#ga4
NULL
)
00333         *exact_match =
group__DBusMacros.html#ga3
FALSE
;
00334
return
(return_deepest_match && subtree->
structDBusObjectSubtree.html#o8
invoke_as_fallback
) ? subtree :
group__DBusMacros.html#ga4
NULL
;
00335     }
00336 }
00337
00338
static
DBusObjectSubtree*
00339 find_subtree (
structDBusObjectTree.html
DBusObjectTree
*tree,
00340
const
char
**path,
00341
int
*index_in_parent)
00342 {
00343   DBusObjectSubtree *subtree;
00344
00345
#if VERBOSE_FIND
00346
_dbus_verbose (
"Looking for exact registered subtree\n"
);
00347
#endif
00348
00349   subtree = find_subtree_recurse (tree->
structDBusObjectTree.html#o2
root
, path,
group__DBusMacros.html#ga3
FALSE
, index_in_parent,
group__DBusMacros.html#ga4
NULL
);
00350
00351
if
(subtree && subtree->
structDBusObjectSubtree.html#o3
message_function
==
group__DBusMacros.html#ga4
NULL
)
00352
return
group__DBusMacros.html#ga4
NULL
;
00353
else
00354
return
subtree;
00355 }
00356
00357
static
DBusObjectSubtree*
00358 lookup_subtree (
structDBusObjectTree.html
DBusObjectTree
*tree,
00359
const
char
**path)
00360 {
00361
#if VERBOSE_FIND
00362
_dbus_verbose (
"Looking for subtree\n"
);
00363
#endif
00364
return
find_subtree_recurse (tree->
structDBusObjectTree.html#o2
root
, path,
group__DBusMacros.html#ga3
FALSE
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00365 }
00366
00367
static
DBusObjectSubtree*
00368 find_handler (
structDBusObjectTree.html
DBusObjectTree
*tree,
00369
const
char
**path,
00370
group__DBusTypes.html#ga2
dbus_bool_t
*exact_match)
00371 {
00372
#if VERBOSE_FIND
00373
_dbus_verbose (
"Looking for deepest handler\n"
);
00374
#endif
00375
group__DBusInternalsUtils.html#ga130
_dbus_assert
(exact_match !=
group__DBusMacros.html#ga4
NULL
);
00376
00377   *exact_match =
group__DBusMacros.html#ga3
FALSE
;
/* ensure always initialized */
00378
00379
return
find_subtree_recurse (tree->
structDBusObjectTree.html#o2
root
, path,
group__DBusMacros.html#ga3
FALSE
,
group__DBusMacros.html#ga4
NULL
, exact_match);
00380 }
00381
00382
static
DBusObjectSubtree*
00383 ensure_subtree (
structDBusObjectTree.html
DBusObjectTree
*tree,
00384
const
char
**path)
00385 {
00386
#if VERBOSE_FIND
00387
_dbus_verbose (
"Ensuring subtree\n"
);
00388
#endif
00389
return
find_subtree_recurse (tree->
structDBusObjectTree.html#o2
root
, path,
group__DBusMacros.html#ga2
TRUE
,
group__DBusMacros.html#ga4
NULL
,
group__DBusMacros.html#ga4
NULL
);
00390 }
00391
00402
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusObjectTree.html#ga15
00403
group__DBusObjectTree.html#ga15
_dbus_object_tree_register
(
structDBusObjectTree.html
DBusObjectTree
*tree,
00404
group__DBusTypes.html#ga2
dbus_bool_t
fallback,
00405
const
char
**path,
00406
const
structDBusObjectPathVTable.html
DBusObjectPathVTable
*vtable,
00407
void
*user_data)
00408 {
00409   DBusObjectSubtree  *subtree;
00410
00411
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree !=
group__DBusMacros.html#ga4
NULL
);
00412
group__DBusInternalsUtils.html#ga130
_dbus_assert
(vtable->
structDBusObjectPathVTable.html#o1
message_function
!=
group__DBusMacros.html#ga4
NULL
);
00413
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path !=
group__DBusMacros.html#ga4
NULL
);
00414
00415   subtree = ensure_subtree (tree, path);
00416
if
(subtree ==
group__DBusMacros.html#ga4
NULL
)
00417
return
group__DBusMacros.html#ga3
FALSE
;
00418
00419
#ifndef DBUS_DISABLE_CHECKS
00420
if
(subtree->
structDBusObjectSubtree.html#o3
message_function
!=
group__DBusMacros.html#ga4
NULL
)
00421     {
00422
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"A handler is already registered for the path starting with path[0] = \"%s\"\n"
,
00423                   path[0] ? path[0] :
"null"
);
00424
return
group__DBusMacros.html#ga3
FALSE
;
00425     }
00426
#else
00427
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o3
message_function
==
group__DBusMacros.html#ga4
NULL
);
00428
#endif
00429
00430   subtree->
structDBusObjectSubtree.html#o3
message_function
= vtable->
structDBusObjectPathVTable.html#o1
message_function
;
00431   subtree->
structDBusObjectSubtree.html#o2
unregister_function
= vtable->
structDBusObjectPathVTable.html#o0
unregister_function
;
00432   subtree->
structDBusObjectSubtree.html#o4
user_data
= user_data;
00433   subtree->
structDBusObjectSubtree.html#o8
invoke_as_fallback
= fallback !=
group__DBusMacros.html#ga3
FALSE
;
00434
00435
return
group__DBusMacros.html#ga2
TRUE
;
00436 }
00437
00445
void
group__DBusObjectTree.html#ga16
00446
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(
structDBusObjectTree.html
DBusObjectTree
*tree,
00447
const
char
**path)
00448 {
00449
int
i;
00450   DBusObjectSubtree *subtree;
00451   DBusObjectPathUnregisterFunction unregister_function;
00452
void
*user_data;
00453
structDBusConnection.html
DBusConnection
*connection;
00454
00455
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path !=
group__DBusMacros.html#ga4
NULL
);
00456
00457   unregister_function =
group__DBusMacros.html#ga4
NULL
;
00458   user_data =
group__DBusMacros.html#ga4
NULL
;
00459
00460   subtree = find_subtree (tree, path, &i);
00461
00462
#ifndef DBUS_DISABLE_CHECKS
00463
if
(subtree ==
group__DBusMacros.html#ga4
NULL
)
00464     {
00465
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n"
,
00466                   path[0] ? path[0] :
"null"
,
00467                   path[1] ? path[1] :
"null"
);
00468
goto
unlock;
00469     }
00470
#else
00471
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree !=
group__DBusMacros.html#ga4
NULL
);
00472
#endif
00473
00474
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o1
parent
==
group__DBusMacros.html#ga4
NULL
||
00475                 (i >= 0 && subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o5
subtrees
[i] == subtree));
00476
00477   subtree->
structDBusObjectSubtree.html#o3
message_function
=
group__DBusMacros.html#ga4
NULL
;
00478
00479   unregister_function = subtree->
structDBusObjectSubtree.html#o2
unregister_function
;
00480   user_data = subtree->
structDBusObjectSubtree.html#o4
user_data
;
00481
00482   subtree->
structDBusObjectSubtree.html#o2
unregister_function
=
group__DBusMacros.html#ga4
NULL
;
00483   subtree->
structDBusObjectSubtree.html#o4
user_data
=
group__DBusMacros.html#ga4
NULL
;
00484
00485
/* If we have no subtrees of our own, remove from
00486
* our parent (FIXME could also be more aggressive
00487
* and remove our parent if it becomes empty)
00488
*/
00489
if
(subtree->
structDBusObjectSubtree.html#o1
parent
&& subtree->
structDBusObjectSubtree.html#o6
n_subtrees
== 0)
00490     {
00491
/* assumes a 0-byte memmove is OK */
00492       memmove (&subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o5
subtrees
[i],
00493                &subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o5
subtrees
[i+1],
00494                (subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o6
n_subtrees
- i - 1) *
00495                sizeof (subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o5
subtrees
[0]));
00496       subtree->
structDBusObjectSubtree.html#o1
parent
->
structDBusObjectSubtree.html#o6
n_subtrees
-= 1;
00497
00498       subtree->
structDBusObjectSubtree.html#o1
parent
=
group__DBusMacros.html#ga4
NULL
;
00499
00500       _dbus_object_subtree_unref (subtree);
00501     }
00502   subtree =
group__DBusMacros.html#ga4
NULL
;
00503
00504 unlock:
00505   connection = tree->
structDBusObjectTree.html#o1
connection
;
00506
00507
/* Unlock and call application code */
00508
#ifdef DBUS_BUILD_TESTS
00509
if
(connection)
00510
#endif
00511
{
00512
group__DBusConnectionInternals.html#ga43
_dbus_connection_ref_unlocked
(connection);
00513       _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
00514
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(connection);
00515     }
00516
00517
if
(unregister_function)
00518     (* unregister_function) (connection, user_data);
00519
00520
#ifdef DBUS_BUILD_TESTS
00521
if
(connection)
00522
#endif
00523
group__DBusConnection.html#ga5
dbus_connection_unref
(connection);
00524 }
00525
00526
static
void
00527 free_subtree_recurse (
structDBusConnection.html
DBusConnection
*connection,
00528                       DBusObjectSubtree *subtree)
00529 {
00530
/* Delete them from the end, for slightly
00531
* more robustness against odd reentrancy.
00532
*/
00533
while
(subtree->
structDBusObjectSubtree.html#o6
n_subtrees
> 0)
00534     {
00535       DBusObjectSubtree *child;
00536
00537       child = subtree->
structDBusObjectSubtree.html#o5
subtrees
[subtree->
structDBusObjectSubtree.html#o6
n_subtrees
- 1];
00538       subtree->
structDBusObjectSubtree.html#o5
subtrees
[subtree->
structDBusObjectSubtree.html#o6
n_subtrees
- 1] =
group__DBusMacros.html#ga4
NULL
;
00539       subtree->
structDBusObjectSubtree.html#o6
n_subtrees
-= 1;
00540       child->
structDBusObjectSubtree.html#o1
parent
=
group__DBusMacros.html#ga4
NULL
;
00541
00542       free_subtree_recurse (connection, child);
00543     }
00544
00545
/* Call application code */
00546
if
(subtree->
structDBusObjectSubtree.html#o2
unregister_function
)
00547     (* subtree->
structDBusObjectSubtree.html#o2
unregister_function
) (connection,
00548                                       subtree->
structDBusObjectSubtree.html#o4
user_data
);
00549
00550   subtree->
structDBusObjectSubtree.html#o3
message_function
=
group__DBusMacros.html#ga4
NULL
;
00551   subtree->
structDBusObjectSubtree.html#o2
unregister_function
=
group__DBusMacros.html#ga4
NULL
;
00552   subtree->
structDBusObjectSubtree.html#o4
user_data
=
group__DBusMacros.html#ga4
NULL
;
00553
00554
/* Now free ourselves */
00555   _dbus_object_subtree_unref (subtree);
00556 }
00557
00564
void
group__DBusObjectTree.html#ga18
00565
group__DBusObjectTree.html#ga18
_dbus_object_tree_free_all_unlocked
(
structDBusObjectTree.html
DBusObjectTree
*tree)
00566 {
00567
if
(tree->
structDBusObjectTree.html#o2
root
)
00568     free_subtree_recurse (tree->
structDBusObjectTree.html#o1
connection
,
00569                           tree->
structDBusObjectTree.html#o2
root
);
00570   tree->
structDBusObjectTree.html#o2
root
=
group__DBusMacros.html#ga4
NULL
;
00571 }
00572
00573
static
group__DBusTypes.html#ga2
dbus_bool_t
00574 _dbus_object_tree_list_registered_unlocked (
structDBusObjectTree.html
DBusObjectTree
*tree,
00575
const
char
**parent_path,
00576
char
***child_entries)
00577 {
00578   DBusObjectSubtree *subtree;
00579
char
**retval;
00580
00581
group__DBusInternalsUtils.html#ga130
_dbus_assert
(parent_path !=
group__DBusMacros.html#ga4
NULL
);
00582
group__DBusInternalsUtils.html#ga130
_dbus_assert
(child_entries !=
group__DBusMacros.html#ga4
NULL
);
00583
00584   *child_entries =
group__DBusMacros.html#ga4
NULL
;
00585
00586   subtree = lookup_subtree (tree, parent_path);
00587
if
(subtree ==
group__DBusMacros.html#ga4
NULL
)
00588     {
00589       retval =
group__DBusMemory.html#ga7
dbus_new0
(
char
*, 1);
00590     }
00591
else
00592     {
00593
int
i;
00594       retval =
group__DBusMemory.html#ga7
dbus_new0
(
char
*, subtree->
structDBusObjectSubtree.html#o6
n_subtrees
+ 1);
00595
if
(retval ==
group__DBusMacros.html#ga4
NULL
)
00596
goto
out;
00597       i = 0;
00598
while
(i < subtree->n_subtrees)
00599         {
00600           retval[i] =
group__DBusInternalsUtils.html#ga8
_dbus_strdup
(subtree->
structDBusObjectSubtree.html#o5
subtrees
[i]->
structDBusObjectSubtree.html#o9
name
);
00601
if
(retval[i] ==
group__DBusMacros.html#ga4
NULL
)
00602             {
00603
group__DBusMemory.html#ga4
dbus_free_string_array
(retval);
00604               retval =
group__DBusMacros.html#ga4
NULL
;
00605
goto
out;
00606             }
00607           ++i;
00608         }
00609     }
00610
00611  out:
00612
00613   *child_entries = retval;
00614
return
retval !=
group__DBusMacros.html#ga4
NULL
;
00615 }
00616
00617
static
DBusHandlerResult
00618 handle_default_introspect_and_unlock (
structDBusObjectTree.html
DBusObjectTree
*tree,
00619
structDBusMessage.html
DBusMessage
*message,
00620
const
char
**path)
00621 {
00622
structDBusString.html
DBusString
xml;
00623   DBusHandlerResult result;
00624
char
**children;
00625
int
i;
00626
structDBusMessage.html
DBusMessage
*reply;
00627
structDBusMessageIter.html
DBusMessageIter
iter;
00628
const
char
*v_STRING;
00629
group__DBusTypes.html#ga2
dbus_bool_t
already_unlocked;
00630
00631
/* We have the connection lock here */
00632
00633   already_unlocked =
group__DBusMacros.html#ga3
FALSE
;
00634
00635   _dbus_verbose (
" considering default Introspect() handler...\n"
);
00636
00637   reply =
group__DBusMacros.html#ga4
NULL
;
00638
00639
if
(!
group__DBusMessage.html#ga69
dbus_message_is_method_call
(message,
00640                                     DBUS_INTERFACE_INTROSPECTABLE,
00641
"Introspect"
))
00642     {
00643
#ifdef DBUS_BUILD_TESTS
00644
if
(tree->
structDBusObjectTree.html#o1
connection
)
00645
#endif
00646
{
00647           _dbus_verbose (
"unlock %s %d\n"
, _DBUS_FUNCTION_NAME, __LINE__);
00648
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00649         }
00650
00651
return
DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
00652     }
00653
00654   _dbus_verbose (
" using default Introspect() handler!\n"
);
00655
00656
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&xml))
00657     {
00658
#ifdef DBUS_BUILD_TESTS
00659
if
(tree->
structDBusObjectTree.html#o1
connection
)
00660
#endif
00661
{
00662           _dbus_verbose (
"unlock %s %d\n"
, _DBUS_FUNCTION_NAME, __LINE__);
00663
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00664         }
00665
00666
return
DBUS_HANDLER_RESULT_NEED_MEMORY;
00667     }
00668
00669   result = DBUS_HANDLER_RESULT_NEED_MEMORY;
00670
00671   children =
group__DBusMacros.html#ga4
NULL
;
00672
if
(!_dbus_object_tree_list_registered_unlocked (tree, path, &children))
00673
goto
out;
00674
00675
if
(!
group__DBusString.html#ga27
_dbus_string_append
(&xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE))
00676
goto
out;
00677
00678
if
(!
group__DBusString.html#ga27
_dbus_string_append
(&xml,
"<node>\n"
))
00679
goto
out;
00680
00681   i = 0;
00682
while
(children[i] !=
group__DBusMacros.html#ga4
NULL
)
00683     {
00684
if
(!
group__DBusString.html#ga33
_dbus_string_append_printf
(&xml,
"  <node name=\"%s\"/>\n"
,
00685                                        children[i]))
00686
goto
out;
00687
00688       ++i;
00689     }
00690
00691
if
(!
group__DBusString.html#ga27
_dbus_string_append
(&xml,
"</node>\n"
))
00692
goto
out;
00693
00694   reply =
group__DBusMessage.html#ga14
dbus_message_new_method_return
(message);
00695
if
(reply ==
group__DBusMacros.html#ga4
NULL
)
00696
goto
out;
00697
00698
group__DBusMessage.html#ga39
dbus_message_iter_init_append
(reply, &iter);
00699   v_STRING = _dbus_string_get_const_data (&xml);
00700
if
(!
group__DBusMessage.html#ga43
dbus_message_iter_append_basic
(&iter, DBUS_TYPE_STRING, &v_STRING))
00701
goto
out;
00702
00703
#ifdef DBUS_BUILD_TESTS
00704
if
(tree->connection)
00705
#endif
00706
{
00707       already_unlocked =
group__DBusMacros.html#ga2
TRUE
;
00708
00709
if
(!
group__DBusConnection.html#ga19
_dbus_connection_send_and_unlock
(tree->connection, reply,
group__DBusMacros.html#ga4
NULL
))
00710
goto
out;
00711     }
00712
00713   result = DBUS_HANDLER_RESULT_HANDLED;
00714
00715  out:
00716
#ifdef DBUS_BUILD_TESTS
00717
if
(tree->connection)
00718
#endif
00719
{
00720
if
(!already_unlocked)
00721         {
00722           _dbus_verbose (
"unlock %s %d\n"
, _DBUS_FUNCTION_NAME, __LINE__);
00723
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->connection);
00724         }
00725     }
00726
00727
group__DBusString.html#ga9
_dbus_string_free
(&xml);
00728
group__DBusMemory.html#ga4
dbus_free_string_array
(children);
00729
if
(reply)
00730
group__DBusMessage.html#ga20
dbus_message_unref
(reply);
00731
00732
return
result;
00733 }
00734
00748 DBusHandlerResult
group__DBusObjectTree.html#ga21
00749
group__DBusObjectTree.html#ga21
_dbus_object_tree_dispatch_and_unlock
(
structDBusObjectTree.html
DBusObjectTree
*tree,
00750
structDBusMessage.html
DBusMessage
*message)
00751 {
00752
char
**path;
00753
group__DBusTypes.html#ga2
dbus_bool_t
exact_match;
00754
structDBusList.html
DBusList
*list;
00755
structDBusList.html
DBusList
*link;
00756   DBusHandlerResult result;
00757   DBusObjectSubtree *subtree;
00758
00759
#if 0
00760
_dbus_verbose (
"Dispatch of message by object path\n"
);
00761
#endif
00762
00763   path =
group__DBusMacros.html#ga4
NULL
;
00764
if
(!
group__DBusMessage.html#ga54
dbus_message_get_path_decomposed
(message, &path))
00765     {
00766
#ifdef DBUS_BUILD_TESTS
00767
if
(tree->
structDBusObjectTree.html#o1
connection
)
00768
#endif
00769
{
00770           _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
00771
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00772         }
00773
00774       _dbus_verbose (
"No memory to get decomposed path\n"
);
00775
00776
return
DBUS_HANDLER_RESULT_NEED_MEMORY;
00777     }
00778
00779
if
(path ==
group__DBusMacros.html#ga4
NULL
)
00780     {
00781
#ifdef DBUS_BUILD_TESTS
00782
if
(tree->
structDBusObjectTree.html#o1
connection
)
00783
#endif
00784
{
00785           _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
00786
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00787         }
00788
00789       _dbus_verbose (
"No path field in message\n"
);
00790
return
DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
00791     }
00792
00793
/* Find the deepest path that covers the path in the message */
00794   subtree = find_handler (tree, (
const
char
**) path, &exact_match);
00795
00796
/* Build a list of all paths that cover the path in the message */
00797
00798   list =
group__DBusMacros.html#ga4
NULL
;
00799
00800
while
(subtree !=
group__DBusMacros.html#ga4
NULL
)
00801     {
00802
if
(subtree->
structDBusObjectSubtree.html#o3
message_function
!=
group__DBusMacros.html#ga4
NULL
&& (exact_match || subtree->
structDBusObjectSubtree.html#o8
invoke_as_fallback
))
00803         {
00804           _dbus_object_subtree_ref (subtree);
00805
00806
/* run deepest paths first */
00807
if
(!
group__DBusList.html#ga2
_dbus_list_append
(&list, subtree))
00808             {
00809               result = DBUS_HANDLER_RESULT_NEED_MEMORY;
00810               _dbus_object_subtree_unref (subtree);
00811
goto
free_and_return;
00812             }
00813         }
00814
00815       exact_match =
group__DBusMacros.html#ga3
FALSE
;
00816       subtree = subtree->
structDBusObjectSubtree.html#o1
parent
;
00817     }
00818
00819   _dbus_verbose (
"%d handlers in the path tree for this message\n"
,
00820
group__DBusList.html#ga21
_dbus_list_get_length
(&list));
00821
00822
/* Invoke each handler in the list */
00823
00824   result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
00825
00826   link =
group__DBusList.html#ga13
_dbus_list_get_first_link
(&list);
00827
while
(link !=
group__DBusMacros.html#ga4
NULL
)
00828     {
00829
structDBusList.html
DBusList
*next =
group__DBusList.html#ga24
_dbus_list_get_next_link
(&list, link);
00830       subtree = link->
structDBusList.html#o2
data
;
00831
00832
/* message_function is NULL if we're unregistered
00833
* due to reentrancy
00834
*/
00835
if
(subtree->
structDBusObjectSubtree.html#o3
message_function
)
00836         {
00837           DBusObjectPathMessageFunction message_function;
00838
void
*user_data;
00839
00840           message_function = subtree->
structDBusObjectSubtree.html#o3
message_function
;
00841           user_data = subtree->
structDBusObjectSubtree.html#o4
user_data
;
00842
00843
#if 0
00844
_dbus_verbose (
"  (invoking a handler)\n"
);
00845
#endif
00846
00847
#ifdef DBUS_BUILD_TESTS
00848
if
(tree->
structDBusObjectTree.html#o1
connection
)
00849
#endif
00850
{
00851               _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
00852
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00853             }
00854
00855
/* FIXME you could unregister the subtree in another thread
00856
* before we invoke the callback, and I can't figure out a
00857
* good way to solve this.
00858
*/
00859
00860           result = (* message_function) (tree->
structDBusObjectTree.html#o1
connection
,
00861                                          message,
00862                                          user_data);
00863
00864
#ifdef DBUS_BUILD_TESTS
00865
if
(tree->
structDBusObjectTree.html#o1
connection
)
00866
#endif
00867
group__DBusConnectionInternals.html#ga16
_dbus_connection_lock
(tree->
structDBusObjectTree.html#o1
connection
);
00868
00869
if
(result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
00870
goto
free_and_return;
00871         }
00872
00873       link = next;
00874     }
00875
00876  free_and_return:
00877
00878
if
(result == DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
00879     {
00880
/* This hardcoded default handler does a minimal Introspect()
00881
*/
00882       result = handle_default_introspect_and_unlock (tree, message,
00883                                                      (
const
char
**) path);
00884     }
00885
else
00886     {
00887
#ifdef DBUS_BUILD_TESTS
00888
if
(tree->
structDBusObjectTree.html#o1
connection
)
00889
#endif
00890
{
00891           _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
00892
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
00893         }
00894     }
00895
00896
while
(list !=
group__DBusMacros.html#ga4
NULL
)
00897     {
00898       link =
group__DBusList.html#ga13
_dbus_list_get_first_link
(&list);
00899       _dbus_object_subtree_unref (link->
structDBusList.html#o2
data
);
00900
group__DBusList.html#ga11
_dbus_list_remove_link
(&list, link);
00901     }
00902
00903
group__DBusMemory.html#ga4
dbus_free_string_array
(path);
00904
00905
return
result;
00906 }
00907
00916
void
*
group__DBusObjectTree.html#ga22
00917
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(
structDBusObjectTree.html
DBusObjectTree
*tree,
00918
const
char
**path)
00919 {
00920
group__DBusTypes.html#ga2
dbus_bool_t
exact_match;
00921   DBusObjectSubtree *subtree;
00922
00923
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree !=
group__DBusMacros.html#ga4
NULL
);
00924
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path !=
group__DBusMacros.html#ga4
NULL
);
00925
00926
/* Find the deepest path that covers the path in the message */
00927   subtree = find_handler (tree, (
const
char
**) path, &exact_match);
00928
00929
if
((subtree ==
group__DBusMacros.html#ga4
NULL
) || !exact_match)
00930     {
00931       _dbus_verbose (
"%s: No object at specified path found\n"
,
00932                      _DBUS_FUNCTION_NAME);
00933
return
group__DBusMacros.html#ga4
NULL
;
00934     }
00935
00936
return
subtree->
structDBusObjectSubtree.html#o4
user_data
;
00937 }
00938
00945
static
DBusObjectSubtree*
00946 allocate_subtree_object (
const
char
*name)
00947 {
00948
int
len;
00949   DBusObjectSubtree *subtree;
00950
const
size_t front_padding = _DBUS_STRUCT_OFFSET (DBusObjectSubtree, name);
00951
00952
group__DBusInternalsUtils.html#ga130
_dbus_assert
(name !=
group__DBusMacros.html#ga4
NULL
);
00953
00954   len = strlen (name);
00955
00956   subtree =
group__DBusMemory.html#ga0
dbus_malloc
(front_padding + (len + 1));
00957
00958
if
(subtree ==
group__DBusMacros.html#ga4
NULL
)
00959
return
group__DBusMacros.html#ga4
NULL
;
00960
00961   memcpy (subtree->
structDBusObjectSubtree.html#o9
name
, name, len + 1);
00962
00963
return
subtree;
00964 }
00965
00966
static
DBusObjectSubtree*
00967 _dbus_object_subtree_new (
const
char
*name,
00968
const
structDBusObjectPathVTable.html
DBusObjectPathVTable
*vtable,
00969
void
*user_data)
00970 {
00971   DBusObjectSubtree *subtree;
00972
00973   subtree = allocate_subtree_object (name);
00974
if
(subtree ==
group__DBusMacros.html#ga4
NULL
)
00975
goto
oom;
00976
00977
group__DBusInternalsUtils.html#ga130
_dbus_assert
(name !=
group__DBusMacros.html#ga4
NULL
);
00978
00979   subtree->
structDBusObjectSubtree.html#o1
parent
=
group__DBusMacros.html#ga4
NULL
;
00980
00981
if
(vtable)
00982     {
00983       subtree->
structDBusObjectSubtree.html#o3
message_function
= vtable->
structDBusObjectPathVTable.html#o1
message_function
;
00984       subtree->
structDBusObjectSubtree.html#o2
unregister_function
= vtable->
structDBusObjectPathVTable.html#o0
unregister_function
;
00985     }
00986
else
00987     {
00988       subtree->
structDBusObjectSubtree.html#o3
message_function
=
group__DBusMacros.html#ga4
NULL
;
00989       subtree->
structDBusObjectSubtree.html#o2
unregister_function
=
group__DBusMacros.html#ga4
NULL
;
00990     }
00991
00992   subtree->
structDBusObjectSubtree.html#o4
user_data
= user_data;
00993   subtree->
structDBusObjectSubtree.html#o0
refcount
.
structDBusAtomic.html#o0
value
= 1;
00994   subtree->
structDBusObjectSubtree.html#o5
subtrees
=
group__DBusMacros.html#ga4
NULL
;
00995   subtree->
structDBusObjectSubtree.html#o6
n_subtrees
= 0;
00996   subtree->
structDBusObjectSubtree.html#o7
subtrees_sorted
=
group__DBusMacros.html#ga2
TRUE
;
00997   subtree->
structDBusObjectSubtree.html#o8
invoke_as_fallback
=
group__DBusMacros.html#ga3
FALSE
;
00998
00999
return
subtree;
01000
01001  oom:
01002
if
(subtree)
01003     {
01004
group__DBusMemory.html#ga3
dbus_free
(subtree);
01005     }
01006
01007
return
group__DBusMacros.html#ga4
NULL
;
01008 }
01009
01010
static
DBusObjectSubtree *
01011 _dbus_object_subtree_ref (DBusObjectSubtree *subtree)
01012 {
01013
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o0
refcount
.
structDBusAtomic.html#o0
value
> 0);
01014
group__DBusInternalsUtils.html#ga80
_dbus_atomic_inc
(&subtree->
structDBusObjectSubtree.html#o0
refcount
);
01015
01016
return
subtree;
01017 }
01018
01019
static
void
01020 _dbus_object_subtree_unref (DBusObjectSubtree *subtree)
01021 {
01022
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o0
refcount
.
structDBusAtomic.html#o0
value
> 0);
01023
01024
if
(
group__DBusInternalsUtils.html#ga81
_dbus_atomic_dec
(&subtree->
structDBusObjectSubtree.html#o0
refcount
) == 1)
01025     {
01026
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o2
unregister_function
==
group__DBusMacros.html#ga4
NULL
);
01027
group__DBusInternalsUtils.html#ga130
_dbus_assert
(subtree->
structDBusObjectSubtree.html#o3
message_function
==
group__DBusMacros.html#ga4
NULL
);
01028
01029
group__DBusMemory.html#ga3
dbus_free
(subtree->
structDBusObjectSubtree.html#o5
subtrees
);
01030
group__DBusMemory.html#ga3
dbus_free
(subtree);
01031     }
01032 }
01033
01044
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusObjectTree.html#ga24
01045
group__DBusObjectTree.html#ga24
_dbus_object_tree_list_registered_and_unlock
(
structDBusObjectTree.html
DBusObjectTree
*tree,
01046
const
char
**parent_path,
01047
char
***child_entries)
01048 {
01049
group__DBusTypes.html#ga2
dbus_bool_t
result;
01050
01051   result = _dbus_object_tree_list_registered_unlocked (tree,
01052                                                        parent_path,
01053                                                        child_entries);
01054
01055
#ifdef DBUS_BUILD_TESTS
01056
if
(tree->
structDBusObjectTree.html#o1
connection
)
01057
#endif
01058
{
01059       _dbus_verbose (
"unlock %s\n"
, _DBUS_FUNCTION_NAME);
01060
group__DBusConnectionInternals.html#ga17
_dbus_connection_unlock
(tree->
structDBusObjectTree.html#o1
connection
);
01061     }
01062
01063
return
result;
01064 }
01065
01066
group__DBusObjectTree.html#ga27
01068
#define VERBOSE_DECOMPOSE 0
01069
01080
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusObjectTree.html#ga25
01081
group__DBusObjectTree.html#ga25
_dbus_decompose_path
(
const
char
*     data,
01082
int
len,
01083
char
***path,
01084
int
*path_len)
01085 {
01086
char
**retval;
01087
int
n_components;
01088
int
i, j, comp;
01089
01090
group__DBusInternalsUtils.html#ga130
_dbus_assert
(data !=
group__DBusMacros.html#ga4
NULL
);
01091
01092
#if VERBOSE_DECOMPOSE
01093
_dbus_verbose (
"Decomposing path \"%s\"\n"
,
01094                  data);
01095
#endif
01096
01097   n_components = 0;
01098
if
(len > 1)
/* if path is not just "/" */
01099     {
01100       i = 0;
01101
while
(i < len)
01102         {
01103
if
(data[i] ==
'/'
)
01104             n_components += 1;
01105           ++i;
01106         }
01107     }
01108
01109   retval =
group__DBusMemory.html#ga7
dbus_new0
(
char
*, n_components + 1);
01110
01111
if
(retval ==
group__DBusMacros.html#ga4
NULL
)
01112
return
group__DBusMacros.html#ga3
FALSE
;
01113
01114   comp = 0;
01115
if
(n_components == 0)
01116     i = 1;
01117
else
01118     i = 0;
01119
while
(comp < n_components)
01120     {
01121
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i < len);
01122
01123
if
(data[i] ==
'/'
)
01124         ++i;
01125       j = i;
01126
01127
while
(j < len && data[j] !=
'/'
)
01128         ++j;
01129
01130
/* Now [i, j) is the path component */
01131
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i < j);
01132
group__DBusInternalsUtils.html#ga130
_dbus_assert
(data[i] !=
'/'
);
01133
group__DBusInternalsUtils.html#ga130
_dbus_assert
(j == len || data[j] ==
'/'
);
01134
01135
#if VERBOSE_DECOMPOSE
01136
_dbus_verbose (
"  (component in [%d,%d))\n"
,
01137                      i, j);
01138
#endif
01139
01140       retval[comp] =
group__DBusInternalsUtils.html#ga9
_dbus_memdup
(&data[i], j - i + 1);
01141
if
(retval[comp] ==
group__DBusMacros.html#ga4
NULL
)
01142         {
01143
group__DBusMemory.html#ga4
dbus_free_string_array
(retval);
01144
return
group__DBusMacros.html#ga3
FALSE
;
01145         }
01146       retval[comp][j-i] =
'\0'
;
01147
#if VERBOSE_DECOMPOSE
01148
_dbus_verbose (
"  (component %d = \"%s\")\n"
,
01149                      comp, retval[comp]);
01150
#endif
01151
01152       ++comp;
01153       i = j;
01154     }
01155
group__DBusInternalsUtils.html#ga130
_dbus_assert
(i == len);
01156
01157   *path = retval;
01158
if
(path_len)
01159     *path_len = n_components;
01160
01161
return
group__DBusMacros.html#ga2
TRUE
;
01162 }
01163
01166
#ifdef DBUS_BUILD_TESTS
01167
#include "dbus-test.h"
01168
#include <stdio.h>
01169
01170
static
char
*
01171 flatten_path (
const
char
**path)
01172 {
01173
structDBusString.html
DBusString
str;
01174
char
*s;
01175
01176
if
(!
group__DBusString.html#ga6
_dbus_string_init
(&str))
01177
return
group__DBusMacros.html#ga4
NULL
;
01178
01179
if
(path[0] ==
group__DBusMacros.html#ga4
NULL
)
01180     {
01181
if
(!
group__DBusString.html#ga35
_dbus_string_append_byte
(&str,
'/'
))
01182
goto
nomem;
01183     }
01184
else
01185     {
01186
int
i;
01187
01188       i = 0;
01189
while
(path[i])
01190         {
01191
if
(!
group__DBusString.html#ga35
_dbus_string_append_byte
(&str,
'/'
))
01192
goto
nomem;
01193
01194
if
(!
group__DBusString.html#ga27
_dbus_string_append
(&str, path[i]))
01195
goto
nomem;
01196
01197           ++i;
01198         }
01199     }
01200
01201
if
(!
group__DBusString.html#ga16
_dbus_string_steal_data
(&str, &s))
01202
goto
nomem;
01203
01204
group__DBusString.html#ga9
_dbus_string_free
(&str);
01205
01206
return
s;
01207
01208  nomem:
01209
group__DBusString.html#ga9
_dbus_string_free
(&str);
01210
return
group__DBusMacros.html#ga4
NULL
;
01211 }
01212
01213
01214
typedef
enum
01215 {
01216   STR_EQUAL,
01217   STR_PREFIX,
01218   STR_DIFFERENT
01219 } StrComparison;
01220
01221
/* Returns TRUE if container is a parent of child
01222
*/
01223
static
StrComparison
01224 path_contains (
const
char
**container,
01225
const
char
**child)
01226 {
01227
int
i;
01228
01229   i = 0;
01230
while
(child[i] !=
group__DBusMacros.html#ga4
NULL
)
01231     {
01232
int
v;
01233
01234
if
(container[i] ==
group__DBusMacros.html#ga4
NULL
)
01235
return
STR_PREFIX;
/* container ran out, child continues;
01236
* thus the container is a parent of the
01237
* child.
01238
*/
01239
01240
group__DBusInternalsUtils.html#ga130
_dbus_assert
(container[i] !=
group__DBusMacros.html#ga4
NULL
);
01241
group__DBusInternalsUtils.html#ga130
_dbus_assert
(child[i] !=
group__DBusMacros.html#ga4
NULL
);
01242
01243       v = strcmp (container[i], child[i]);
01244
01245
if
(v != 0)
01246
return
STR_DIFFERENT;
/* they overlap until here and then are different,
01247
* not overlapping
01248
*/
01249
01250       ++i;
01251     }
01252
01253
/* Child ran out; if container also did, they are equal;
01254
* otherwise, the child is a parent of the container.
01255
*/
01256
if
(container[i] ==
group__DBusMacros.html#ga4
NULL
)
01257
return
STR_EQUAL;
01258
else
01259
return
STR_DIFFERENT;
01260 }
01261
01262
#if 0
01263
static
void
01264 spew_subtree_recurse (DBusObjectSubtree *subtree,
01265
int
indent)
01266 {
01267
int
i;
01268
01269   i = 0;
01270
while
(i < indent)
01271     {
01272       _dbus_verbose (
" "
);
01273       ++i;
01274     }
01275
01276   _dbus_verbose (
"%s (%d children)\n"
,
01277                  subtree->
structDBusObjectSubtree.html#o9
name
, subtree->
structDBusObjectSubtree.html#o6
n_subtrees
);
01278
01279   i = 0;
01280
while
(i < subtree->n_subtrees)
01281     {
01282       spew_subtree_recurse (subtree->
structDBusObjectSubtree.html#o5
subtrees
[i], indent + 2);
01283
01284       ++i;
01285     }
01286 }
01287
01288
static
void
01289 spew_tree (
structDBusObjectTree.html
DBusObjectTree
*tree)
01290 {
01291   spew_subtree_recurse (tree->
structDBusObjectTree.html#o2
root
, 0);
01292 }
01293
#endif
01294
01298
typedef
struct
01299
{
01300
const
char
**path;
01301
group__DBusTypes.html#ga2
dbus_bool_t
handler_fallback;
01302
group__DBusTypes.html#ga2
dbus_bool_t
message_handled;
01303
group__DBusTypes.html#ga2
dbus_bool_t
handler_unregistered;
01304 } TreeTestData;
01305
01306
01307
static
void
01308 test_unregister_function (
structDBusConnection.html
DBusConnection
*connection,
01309
void
*user_data)
01310 {
01311   TreeTestData *ttd = user_data;
01312
01313   ttd->handler_unregistered =
group__DBusMacros.html#ga2
TRUE
;
01314 }
01315
01316
static
DBusHandlerResult
01317 test_message_function (
structDBusConnection.html
DBusConnection
*connection,
01318
structDBusMessage.html
DBusMessage
*message,
01319
void
*user_data)
01320 {
01321   TreeTestData *ttd = user_data;
01322
01323   ttd->message_handled =
group__DBusMacros.html#ga2
TRUE
;
01324
01325
return
DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
01326 }
01327
01328
static
group__DBusTypes.html#ga2
dbus_bool_t
01329 do_register (
structDBusObjectTree.html
DBusObjectTree
*tree,
01330
const
char
**path,
01331
group__DBusTypes.html#ga2
dbus_bool_t
fallback,
01332
int
i,
01333              TreeTestData   *tree_test_data)
01334 {
01335
structDBusObjectPathVTable.html
DBusObjectPathVTable
vtable = { test_unregister_function,
01336                                   test_message_function,
group__DBusMacros.html#ga4
NULL
};
01337
01338   tree_test_data[i].message_handled =
group__DBusMacros.html#ga3
FALSE
;
01339   tree_test_data[i].handler_unregistered =
group__DBusMacros.html#ga3
FALSE
;
01340   tree_test_data[i].handler_fallback = fallback;
01341   tree_test_data[i].path = path;
01342
01343
if
(!
group__DBusObjectTree.html#ga15
_dbus_object_tree_register
(tree, fallback, path,
01344                                    &vtable,
01345                                    &tree_test_data[i]))
01346
return
group__DBusMacros.html#ga3
FALSE
;
01347
01348
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path) ==
01349                 &tree_test_data[i]);
01350
01351
return
group__DBusMacros.html#ga2
TRUE
;
01352 }
01353
01354
static
group__DBusTypes.html#ga2
dbus_bool_t
01355 do_test_dispatch (
structDBusObjectTree.html
DBusObjectTree
*tree,
01356
const
char
**path,
01357
int
i,
01358                   TreeTestData   *tree_test_data,
01359
int
n_test_data)
01360 {
01361
structDBusMessage.html
DBusMessage
*message;
01362
int
j;
01363   DBusHandlerResult result;
01364
char
*flat;
01365
01366   message = NULL;
01367
01368   flat = flatten_path (path);
01369
if
(flat == NULL)
01370
goto
oom;
01371
01372   message =
group__DBusMessage.html#ga13
dbus_message_new_method_call
(NULL,
01373                                           flat,
01374
"org.freedesktop.TestInterface"
,
01375
"Foo"
);
01376
group__DBusMemory.html#ga3
dbus_free
(flat);
01377
if
(message == NULL)
01378
goto
oom;
01379
01380   j = 0;
01381
while
(j < n_test_data)
01382     {
01383       tree_test_data[j].message_handled =
group__DBusMacros.html#ga3
FALSE
;
01384       ++j;
01385     }
01386
01387   result =
group__DBusObjectTree.html#ga21
_dbus_object_tree_dispatch_and_unlock
(tree, message);
01388
if
(result == DBUS_HANDLER_RESULT_NEED_MEMORY)
01389
goto
oom;
01390
01391
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree_test_data[i].message_handled);
01392
01393   j = 0;
01394
while
(j < n_test_data)
01395     {
01396
if
(tree_test_data[j].message_handled)
01397         {
01398
if
(tree_test_data[j].handler_fallback)
01399
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path_contains (tree_test_data[j].path,
01400                                          path) != STR_DIFFERENT);
01401
else
01402
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path_contains (tree_test_data[j].path, path) == STR_EQUAL);
01403         }
01404
else
01405         {
01406
if
(tree_test_data[j].handler_fallback)
01407
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path_contains (tree_test_data[j].path,
01408                                          path) == STR_DIFFERENT);
01409
else
01410
group__DBusInternalsUtils.html#ga130
_dbus_assert
(path_contains (tree_test_data[j].path, path) != STR_EQUAL);
01411         }
01412
01413       ++j;
01414     }
01415
01416
group__DBusMessage.html#ga20
dbus_message_unref
(message);
01417
01418
return
group__DBusMacros.html#ga2
TRUE
;
01419
01420  oom:
01421
if
(message)
01422
group__DBusMessage.html#ga20
dbus_message_unref
(message);
01423
return
group__DBusMacros.html#ga3
FALSE
;
01424 }
01425
01426
static
size_t
01427 string_array_length (
const
char
**array)
01428 {
01429   size_t i;
01430
for
(i = 0; array[i]; i++) ;
01431
return
i;
01432 }
01433
01434
typedef
struct
01435
{
01436
const
char
*path;
01437
const
char
*result[20];
01438 } DecomposePathTest;
01439
01440
static
DecomposePathTest decompose_tests[] = {
01441   {
"/foo"
, {
"foo"
, NULL } },
01442   {
"/foo/bar"
, {
"foo"
,
"bar"
, NULL } },
01443   {
"/"
, { NULL } },
01444   {
"/a/b"
, {
"a"
,
"b"
, NULL } },
01445   {
"/a/b/c"
, {
"a"
,
"b"
,
"c"
, NULL } },
01446   {
"/a/b/c/d"
, {
"a"
,
"b"
,
"c"
,
"d"
, NULL } },
01447   {
"/foo/bar/q"
, {
"foo"
,
"bar"
,
"q"
, NULL } },
01448   {
"/foo/bar/this/is/longer"
, {
"foo"
,
"bar"
,
"this"
,
"is"
,
"longer"
, NULL } }
01449 };
01450
01451
static
group__DBusTypes.html#ga2
dbus_bool_t
01452 run_decompose_tests (
void
)
01453 {
01454
int
i;
01455
01456   i = 0;
01457
while
(i <
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(decompose_tests))
01458     {
01459
char
**result;
01460
int
result_len;
01461
int
expected_len;
01462
01463
if
(!
group__DBusObjectTree.html#ga25
_dbus_decompose_path
(decompose_tests[i].path,
01464                                  strlen (decompose_tests[i].path),
01465                                  &result, &result_len))
01466
return
group__DBusMacros.html#ga3
FALSE
;
01467
01468       expected_len = string_array_length (decompose_tests[i].result);
01469
01470
if
(result_len != (
int
) string_array_length ((
const
char
**)result) ||
01471           expected_len != result_len ||
01472           path_contains (decompose_tests[i].result,
01473                          (
const
char
**) result) != STR_EQUAL)
01474         {
01475
int
real_len = string_array_length ((
const
char
**)result);
01476
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Expected decompose of %s to have len %d, returned %d, appears to have %d\n"
,
01477                       decompose_tests[i].path, expected_len, result_len,
01478                       real_len);
01479
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"Decompose resulted in elements: { "
);
01480           i = 0;
01481
while
(i < real_len)
01482             {
01483
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"\"%s\"%s"
, result[i],
01484                           (i + 1) == real_len ?
""
:
", "
);
01485               ++i;
01486             }
01487
group__DBusInternalsUtils.html#ga7
_dbus_warn
(
"}\n"
);
01488
group__DBusInternalsUtils.html#ga131
_dbus_assert_not_reached
(
"path decompose failed\n"
);
01489         }
01490
01491
group__DBusMemory.html#ga4
dbus_free_string_array
(result);
01492
01493       ++i;
01494     }
01495
01496
return
group__DBusMacros.html#ga2
TRUE
;
01497 }
01498
01499
static
group__DBusTypes.html#ga2
dbus_bool_t
01500 object_tree_test_iteration (
void
*data)
01501 {
01502
const
char
*path0[] = { NULL };
01503
const
char
*path1[] = {
"foo"
, NULL };
01504
const
char
*path2[] = {
"foo"
,
"bar"
, NULL };
01505
const
char
*path3[] = {
"foo"
,
"bar"
,
"baz"
, NULL };
01506
const
char
*path4[] = {
"foo"
,
"bar"
,
"boo"
, NULL };
01507
const
char
*path5[] = {
"blah"
, NULL };
01508
const
char
*path6[] = {
"blah"
,
"boof"
, NULL };
01509
const
char
*path7[] = {
"blah"
,
"boof"
,
"this"
,
"is"
,
"really"
,
"long"
, NULL };
01510
const
char
*path8[] = {
"childless"
, NULL };
01511
structDBusObjectTree.html
DBusObjectTree
*tree;
01512   TreeTestData tree_test_data[9];
01513
int
i;
01514
group__DBusTypes.html#ga2
dbus_bool_t
exact_match;
01515
01516
if
(!run_decompose_tests ())
01517
return
group__DBusMacros.html#ga3
FALSE
;
01518
01519   tree = NULL;
01520
01521   tree =
group__DBusObjectTree.html#ga4
_dbus_object_tree_new
(NULL);
01522
if
(tree == NULL)
01523
goto
out;
01524
01525
if
(!do_register (tree, path0,
group__DBusMacros.html#ga2
TRUE
, 0, tree_test_data))
01526
goto
out;
01527
01528
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01529
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01530
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01531
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01532
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01533
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01534
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01535
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01536
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01537
01538
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path0, &exact_match) && exact_match);
01539
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path1, &exact_match) == tree->root && !exact_match);
01540
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path2, &exact_match) == tree->root && !exact_match);
01541
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path3, &exact_match) == tree->root && !exact_match);
01542
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path4, &exact_match) == tree->root && !exact_match);
01543
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path5, &exact_match) == tree->root && !exact_match);
01544
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path6, &exact_match) == tree->root && !exact_match);
01545
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path7, &exact_match) == tree->root && !exact_match);
01546
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path8, &exact_match) == tree->root && !exact_match);
01547
01548
if
(!do_register (tree, path1,
group__DBusMacros.html#ga2
TRUE
, 1, tree_test_data))
01549
goto
out;
01550
01551
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01552
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01553
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01554
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01555
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01556
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01557
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01558
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01559
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01560
01561
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path0, &exact_match) &&  exact_match);
01562
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path1, &exact_match) &&  exact_match);
01563
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path2, &exact_match) && !exact_match);
01564
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path3, &exact_match) && !exact_match);
01565
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path4, &exact_match) && !exact_match);
01566
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path5, &exact_match) == tree->root && !exact_match);
01567
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path6, &exact_match) == tree->root && !exact_match);
01568
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path7, &exact_match) == tree->root && !exact_match);
01569
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path8, &exact_match) == tree->root && !exact_match);
01570
01571
if
(!do_register (tree, path2,
group__DBusMacros.html#ga2
TRUE
, 2, tree_test_data))
01572
goto
out;
01573
01574
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01575
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01576
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01577
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01578
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01579
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01580
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01581
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01582
01583
if
(!do_register (tree, path3,
group__DBusMacros.html#ga2
TRUE
, 3, tree_test_data))
01584
goto
out;
01585
01586
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01587
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01588
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01589
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01590
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01591
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01592
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01593
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01594
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01595
01596
if
(!do_register (tree, path4,
group__DBusMacros.html#ga2
TRUE
, 4, tree_test_data))
01597
goto
out;
01598
01599
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01600
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01601
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01602
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01603
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01604
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01605
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01606
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01607
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01608
01609
if
(!do_register (tree, path5,
group__DBusMacros.html#ga2
TRUE
, 5, tree_test_data))
01610
goto
out;
01611
01612
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01613
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01614
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01615
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01616
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01617
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01618
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01619
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01620
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01621
01622
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path0, &exact_match) == tree->root &&  exact_match);
01623
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path1, &exact_match) != tree->root &&  exact_match);
01624
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path2, &exact_match) != tree->root &&  exact_match);
01625
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path3, &exact_match) != tree->root &&  exact_match);
01626
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path4, &exact_match) != tree->root &&  exact_match);
01627
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path5, &exact_match) != tree->root &&  exact_match);
01628
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path6, &exact_match) != tree->root && !exact_match);
01629
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path7, &exact_match) != tree->root && !exact_match);
01630
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path8, &exact_match) == tree->root && !exact_match);
01631
01632
if
(!do_register (tree, path6,
group__DBusMacros.html#ga2
TRUE
, 6, tree_test_data))
01633
goto
out;
01634
01635
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01636
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01637
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01638
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01639
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01640
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01641
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01642
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01643
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01644
01645
if
(!do_register (tree, path7,
group__DBusMacros.html#ga2
TRUE
, 7, tree_test_data))
01646
goto
out;
01647
01648
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01649
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01650
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01651
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01652
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01653
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01654
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01655
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01656
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01657
01658
if
(!do_register (tree, path8,
group__DBusMacros.html#ga2
TRUE
, 8, tree_test_data))
01659
goto
out;
01660
01661
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path0, NULL));
01662
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01663
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01664
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01665
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01666
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01667
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01668
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01669
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01670
01671
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path0, &exact_match) == tree->root &&  exact_match);
01672
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path1, &exact_match) != tree->root && exact_match);
01673
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path2, &exact_match) != tree->root && exact_match);
01674
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path3, &exact_match) != tree->root && exact_match);
01675
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path4, &exact_match) != tree->root && exact_match);
01676
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path5, &exact_match) != tree->root && exact_match);
01677
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path6, &exact_match) != tree->root && exact_match);
01678
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path7, &exact_match) != tree->root && exact_match);
01679
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_handler (tree, path8, &exact_match) != tree->root && exact_match);
01680
01681
/* test the list_registered function */
01682
01683   {
01684
const
char
*root[] = { NULL };
01685
char
**child_entries;
01686
int
nb;
01687
01688     _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries);
01689
if
(child_entries != NULL)
01690       {
01691         nb = string_array_length ((
const
char
**)child_entries);
01692
group__DBusInternalsUtils.html#ga130
_dbus_assert
(nb == 1);
01693
group__DBusMemory.html#ga4
dbus_free_string_array
(child_entries);
01694       }
01695
01696     _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries);
01697
if
(child_entries != NULL)
01698       {
01699         nb = string_array_length ((
const
char
**)child_entries);
01700
group__DBusInternalsUtils.html#ga130
_dbus_assert
(nb == 2);
01701
group__DBusMemory.html#ga4
dbus_free_string_array
(child_entries);
01702       }
01703
01704     _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries);
01705
if
(child_entries != NULL)
01706       {
01707         nb = string_array_length ((
const
char
**)child_entries);
01708
group__DBusInternalsUtils.html#ga130
_dbus_assert
(nb == 0);
01709
group__DBusMemory.html#ga4
dbus_free_string_array
(child_entries);
01710       }
01711
01712     _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries);
01713
if
(child_entries != NULL)
01714       {
01715         nb = string_array_length ((
const
char
**)child_entries);
01716
group__DBusInternalsUtils.html#ga130
_dbus_assert
(nb == 3);
01717
group__DBusMemory.html#ga4
dbus_free_string_array
(child_entries);
01718       }
01719   }
01720
01721
/* Check that destroying tree calls unregister funcs */
01722
group__DBusObjectTree.html#ga6
_dbus_object_tree_unref
(tree);
01723
01724   i = 0;
01725
while
(i < (
int
)
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data))
01726     {
01727
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree_test_data[i].handler_unregistered);
01728
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!tree_test_data[i].message_handled);
01729       ++i;
01730     }
01731
01732
/* Now start again and try the individual unregister function */
01733   tree =
group__DBusObjectTree.html#ga4
_dbus_object_tree_new
(NULL);
01734
if
(tree == NULL)
01735
goto
out;
01736
01737
if
(!do_register (tree, path0,
group__DBusMacros.html#ga2
TRUE
, 0, tree_test_data))
01738
goto
out;
01739
if
(!do_register (tree, path1,
group__DBusMacros.html#ga2
TRUE
, 1, tree_test_data))
01740
goto
out;
01741
if
(!do_register (tree, path2,
group__DBusMacros.html#ga2
TRUE
, 2, tree_test_data))
01742
goto
out;
01743
if
(!do_register (tree, path3,
group__DBusMacros.html#ga2
TRUE
, 3, tree_test_data))
01744
goto
out;
01745
if
(!do_register (tree, path4,
group__DBusMacros.html#ga2
TRUE
, 4, tree_test_data))
01746
goto
out;
01747
if
(!do_register (tree, path5,
group__DBusMacros.html#ga2
TRUE
, 5, tree_test_data))
01748
goto
out;
01749
if
(!do_register (tree, path6,
group__DBusMacros.html#ga2
TRUE
, 6, tree_test_data))
01750
goto
out;
01751
if
(!do_register (tree, path7,
group__DBusMacros.html#ga2
TRUE
, 7, tree_test_data))
01752
goto
out;
01753
if
(!do_register (tree, path8,
group__DBusMacros.html#ga2
TRUE
, 8, tree_test_data))
01754
goto
out;
01755
01756
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path0);
01757
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path0) == NULL);
01758
01759
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01760
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path1, NULL));
01761
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01762
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01763
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01764
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01765
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01766
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01767
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01768
01769
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path1);
01770
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path1) == NULL);
01771
01772
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01773
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01774
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path2, NULL));
01775
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01776
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01777
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01778
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01779
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01780
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01781
01782
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path2);
01783
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path2) == NULL);
01784
01785
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01786
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01787
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01788
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path3, NULL));
01789
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01790
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01791
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01792
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01793
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01794
01795
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path3);
01796
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path3) == NULL);
01797
01798
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01799
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01800
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01801
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01802
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path4, NULL));
01803
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01804
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01805
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01806
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01807
01808
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path4);
01809
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path4) == NULL);
01810
01811
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01812
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01813
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01814
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01815
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01816
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path5, NULL));
01817
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01818
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01819
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01820
01821
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path5);
01822
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path5) == NULL);
01823
01824
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01825
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01826
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01827
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01828
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01829
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01830
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path6, NULL));
01831
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01832
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01833
01834
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path6);
01835
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path6) == NULL);
01836
01837
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01838
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01839
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01840
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01841
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01842
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01843
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01844
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path7, NULL));
01845
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01846
01847
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path7);
01848
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path7) == NULL);
01849
01850
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01851
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01852
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01853
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01854
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01855
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01856
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01857
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01858
group__DBusInternalsUtils.html#ga130
_dbus_assert
(find_subtree (tree, path8, NULL));
01859
01860
group__DBusObjectTree.html#ga16
_dbus_object_tree_unregister_and_unlock
(tree, path8);
01861
group__DBusInternalsUtils.html#ga130
_dbus_assert
(
group__DBusObjectTree.html#ga22
_dbus_object_tree_get_user_data_unlocked
(tree, path8) == NULL);
01862
01863
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path0, NULL));
01864
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path1, NULL));
01865
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path2, NULL));
01866
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path3, NULL));
01867
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path4, NULL));
01868
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path5, NULL));
01869
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path6, NULL));
01870
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path7, NULL));
01871
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!find_subtree (tree, path8, NULL));
01872
01873   i = 0;
01874
while
(i < (
int
)
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data))
01875     {
01876
group__DBusInternalsUtils.html#ga130
_dbus_assert
(tree_test_data[i].handler_unregistered);
01877
group__DBusInternalsUtils.html#ga130
_dbus_assert
(!tree_test_data[i].message_handled);
01878       ++i;
01879     }
01880
01881
/* Register it all again, and test dispatch */
01882
01883
if
(!do_register (tree, path0,
group__DBusMacros.html#ga2
TRUE
, 0, tree_test_data))
01884
goto
out;
01885
if
(!do_register (tree, path1,
group__DBusMacros.html#ga3
FALSE
, 1, tree_test_data))
01886
goto
out;
01887
if
(!do_register (tree, path2,
group__DBusMacros.html#ga2
TRUE
, 2, tree_test_data))
01888
goto
out;
01889
if
(!do_register (tree, path3,
group__DBusMacros.html#ga2
TRUE
, 3, tree_test_data))
01890
goto
out;
01891
if
(!do_register (tree, path4,
group__DBusMacros.html#ga2
TRUE
, 4, tree_test_data))
01892
goto
out;
01893
if
(!do_register (tree, path5,
group__DBusMacros.html#ga2
TRUE
, 5, tree_test_data))
01894
goto
out;
01895
if
(!do_register (tree, path6,
group__DBusMacros.html#ga3
FALSE
, 6, tree_test_data))
01896
goto
out;
01897
if
(!do_register (tree, path7,
group__DBusMacros.html#ga2
TRUE
, 7, tree_test_data))
01898
goto
out;
01899
if
(!do_register (tree, path8,
group__DBusMacros.html#ga2
TRUE
, 8, tree_test_data))
01900
goto
out;
01901
01902
#if 0
01903
spew_tree (tree);
01904
#endif
01905
01906
if
(!do_test_dispatch (tree, path0, 0, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01907
goto
out;
01908
if
(!do_test_dispatch (tree, path1, 1, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01909
goto
out;
01910
if
(!do_test_dispatch (tree, path2, 2, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01911
goto
out;
01912
if
(!do_test_dispatch (tree, path3, 3, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01913
goto
out;
01914
if
(!do_test_dispatch (tree, path4, 4, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01915
goto
out;
01916
if
(!do_test_dispatch (tree, path5, 5, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01917
goto
out;
01918
if
(!do_test_dispatch (tree, path6, 6, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01919
goto
out;
01920
if
(!do_test_dispatch (tree, path7, 7, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01921
goto
out;
01922
if
(!do_test_dispatch (tree, path8, 8, tree_test_data,
group__DBusInternalsUtils.html#ga132
_DBUS_N_ELEMENTS
(tree_test_data)))
01923
goto
out;
01924
01925  out:
01926
if
(tree)
01927     {
01928
/* test ref */
01929
group__DBusObjectTree.html#ga5
_dbus_object_tree_ref
(tree);
01930
group__DBusObjectTree.html#ga6
_dbus_object_tree_unref
(tree);
01931
group__DBusObjectTree.html#ga6
_dbus_object_tree_unref
(tree);
01932     }
01933
01934
return
group__DBusMacros.html#ga2
TRUE
;
01935 }
01936
01942
group__DBusTypes.html#ga2
dbus_bool_t
01943 _dbus_object_tree_test (
void
)
01944 {
01945   _dbus_test_oom_handling (
"object tree"
,
01946                            object_tree_test_iteration,
01947                            NULL);
01948
01949
return
group__DBusMacros.html#ga2
TRUE
;
01950 }
01951
01952
#endif
/* DBUS_BUILD_TESTS */
Generated on Tue Sep 13 01:28:07 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
