1 /*
2 * Port for usage with qt-framework and development for kdesvn
3 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
4 * http://kdesvn.alwins-world.de
5 */
6 /*
7 * ====================================================================
8 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved.
9 * dev@rapidsvn.tigris.org
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library (in the file LGPL.txt); if not,
23 * write to the Free Software Foundation, Inc., 51 Franklin St,
24 * Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 * This software consists of voluntary contributions made by many
27 * individuals. For exact contribution history, see the revision
28 * history and logs, available at http://rapidsvn.tigris.org/.
29 * ====================================================================
30 */
31
32
33 // svncpp
34 #include "client_impl.h"
35
36 // subversion api
37 #include <svn_client.h>
38 #include <svn_path.h>
39 #include <svn_sorts.h>
40
41 #include "dirent.h"
42 #include "exception.h"
43 #include "svnqt_defines.h"
44 #include "helper.h"
45
46 namespace svn
47 {
48
49 struct ListBaton {
50 ContextWP context;
51 DirEntries dirEntries;
52 };
53
s_list_func(void * baton,const char * path,const svn_dirent_t * dirent,const svn_lock_t * lock,const char * abs_path,apr_pool_t *)54 static svn_error_t *s_list_func
55 (void *baton, const char *path, const svn_dirent_t *dirent, const svn_lock_t *lock, const char *abs_path, apr_pool_t *)
56 {
57 Q_UNUSED(abs_path);
58 if (!baton || !path || !dirent) {
59 return nullptr;
60 }
61 /* check every loop for cancel of operation */
62 ListBaton *l_baton = static_cast<ListBaton *>(baton);
63 ContextP l_context = l_baton->context;
64 if (l_context.isNull()) {
65 return SVN_NO_ERROR;
66 }
67 svn_client_ctx_t *ctx = l_context->ctx();
68 if (ctx && ctx->cancel_func) {
69 SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
70 }
71 l_context->contextAddListItem(&l_baton->dirEntries, dirent, lock, QString::fromUtf8(path));
72 return nullptr;
73 }
74
75 DirEntries
list(const Path & pathOrUrl,const Revision & revision,const Revision & peg,Depth depth,bool retrieve_locks)76 Client_impl::list(const Path &pathOrUrl,
77 const Revision &revision,
78 const Revision &peg,
79 Depth depth, bool retrieve_locks)
80 {
81
82 ListBaton _baton;
83 Pool pool;
84 // todo svn 1.8: svn_client_list3
85 _baton.context = m_context;
86 svn_error_t *error = svn_client_list2(pathOrUrl.cstr(),
87 peg,
88 revision,
89 svn::internal::DepthToSvn(depth),
90 SVN_DIRENT_ALL,
91 retrieve_locks,
92 s_list_func,
93 &_baton,
94 *m_context,
95 pool
96 );
97 if (error != nullptr) {
98 throw ClientException(error);
99 }
100 return _baton.dirEntries;
101 }
102 }
103
104 /* -----------------------------------------------------------------
105 * local variables:
106 * eval: (load-file "../../rapidsvn-dev.el")
107 * end:
108 */
109