File indexing completed on 2024-05-12 17:16:21

0001 /*
0002  * Port for usage with qt-framework and development for kdesvn
0003  * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
0004  * http://kdesvn.alwins-world.de
0005  */
0006 /*
0007  * ====================================================================
0008  * Copyright (c) 2002-2005 The RapidSvn Group.  All rights reserved.
0009  * dev@rapidsvn.tigris.org
0010  *
0011  * This library is free software; you can redistribute it and/or
0012  * modify it under the terms of the GNU Lesser General Public
0013  * License as published by the Free Software Foundation; either
0014  * version 2.1 of the License, or (at your option) any later version.
0015  *
0016  * This library is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019  * Lesser General Public License for more details.
0020  *
0021  * You should have received a copy of the GNU Lesser General Public
0022  * License along with this library (in the file LGPL.txt); if not,
0023  * write to the Free Software Foundation, Inc., 51 Franklin St,
0024  * Fifth Floor, Boston, MA  02110-1301  USA
0025  *
0026  * This software consists of voluntary contributions made by many
0027  * individuals.  For exact contribution history, see the revision
0028  * history and logs, available at http://rapidsvn.tigris.org/.
0029  * ====================================================================
0030  */
0031 
0032 
0033 // svncpp
0034 #include "client_impl.h"
0035 
0036 // subversion api
0037 #include <svn_client.h>
0038 #include <svn_path.h>
0039 #include <svn_sorts.h>
0040 
0041 #include "dirent.h"
0042 #include "exception.h"
0043 #include "svnqt_defines.h"
0044 #include "helper.h"
0045 
0046 namespace svn
0047 {
0048 
0049 struct ListBaton {
0050     ContextWP context;
0051     DirEntries dirEntries;
0052 };
0053 
0054 static svn_error_t *s_list_func
0055 (void *baton, const char *path, const svn_dirent_t *dirent, const svn_lock_t *lock, const char *abs_path, apr_pool_t *)
0056 {
0057     Q_UNUSED(abs_path);
0058     if (!baton || !path || !dirent) {
0059         return nullptr;
0060     }
0061     /* check every loop for cancel of operation */
0062     ListBaton *l_baton = static_cast<ListBaton *>(baton);
0063     ContextP l_context = l_baton->context;
0064     if (l_context.isNull()) {
0065         return SVN_NO_ERROR;
0066     }
0067     svn_client_ctx_t *ctx = l_context->ctx();
0068     if (ctx && ctx->cancel_func) {
0069         SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
0070     }
0071     l_context->contextAddListItem(&l_baton->dirEntries, dirent, lock, QString::fromUtf8(path));
0072     return nullptr;
0073 }
0074 
0075 DirEntries
0076 Client_impl::list(const Path &pathOrUrl,
0077                   const Revision &revision,
0078                   const Revision &peg,
0079                   Depth depth, bool retrieve_locks)
0080 {
0081 
0082     ListBaton _baton;
0083     Pool pool;
0084     // todo svn 1.8: svn_client_list3
0085     _baton.context = m_context;
0086     svn_error_t *error = svn_client_list2(pathOrUrl.cstr(),
0087                                           peg,
0088                                           revision,
0089                                           svn::internal::DepthToSvn(depth),
0090                                           SVN_DIRENT_ALL,
0091                                           retrieve_locks,
0092                                           s_list_func,
0093                                           &_baton,
0094                                           *m_context,
0095                                           pool
0096                                          );
0097     if (error != nullptr) {
0098         throw ClientException(error);
0099     }
0100     return _baton.dirEntries;
0101 }
0102 }
0103 
0104 /* -----------------------------------------------------------------
0105  * local variables:
0106  * eval: (load-file "../../rapidsvn-dev.el")
0107  * end:
0108  */