1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file RemoteSession.h
24  * @brief Interface of the class RemoteSession
25  */
26 
27 #ifndef JAVAHL_REMOTE_SESSION_H
28 #define JAVAHL_REMOTE_SESSION_H
29 
30 #include <jni.h>
31 
32 #include "svn_ra.h"
33 
34 #include "SVNBase.h"
35 #include "RemoteSessionContext.h"
36 #include "Prompter.h"
37 
38 class CommitEditor;
39 
40 /*
41  * This class wraps Ra based operations from svn_ra.h
42  */
43 class RemoteSession : public SVNBase
44 {
45   public:
46     static RemoteSession* getCppObject(jobject jthis);
47     static jobject open(jint jretryAttempts,
48                         jstring jurl, jstring juuid,
49                         jstring jconfigDirectory,
50                         jstring jusername, jstring jpassword,
51                         jobject jprompter, jobject jdeprecatedPrompter,
52                         jobject jprogress, jobject jcfgcb, jobject jtunnelcb);
53     static jobject open(jint jretryAttempts,
54                         const char* url, const char* uuid,
55                         const char* configDirectory,
56                         const char* username, const char* password,
57                         Prompter::UniquePtr prompter, jobject jprogress,
58                         jobject jcfgcb, jobject jtunnelcb);
59     virtual ~RemoteSession();
60 
cancelOperation()61     void cancelOperation() const { m_context->cancelOperation(); }
62 
63     virtual void dispose(jobject jthis);
64 
65     void reparent(jstring jurl);
66     jstring getSessionUrl();
67     jstring getSessionRelativePath(jstring jurl);
68     jstring getReposRelativePath(jstring jurl);
69     jstring getReposUUID();
70     jstring getReposRootUrl();
71     jlong getLatestRevision();
72     jlong getRevisionByTimestamp(jlong jtimestamp);
73     void changeRevisionProperty(jlong jrevision, jstring jname,
74                                 jbyteArray jold_propval,
75                                 jbyteArray jpropval);
76     jobject getRevisionProperties(jlong jrevision);
77     jbyteArray getRevisionProperty(jlong jrevision, jstring jname);
78     jlong getFile(jlong jrevision, jstring jpath,
79                   jobject jcontents, jobject jproperties);
80     jlong getDirectory(jlong jrevision, jstring jpath, jint jdirent_fields,
81                        jobject jdirents, jobject jproperties);
82     jobject getMergeinfo(jobject jpaths, jlong jrevision, jobject jinherit,
83                          jboolean jinclude_descendants);
84     // TODO: update
85     // TODO: switch
86     void status(jobject jthis, jstring jstatus_target,
87                 jlong jrevision, jobject jdepth,
88                 jobject jstatus_editor, jobject jreporter);
89     // TODO: diff
90     void getLog(jobject jpaths, jlong jstartrev, jlong jendrev, jint jlimit,
91                 jboolean jstrict_node_history, jboolean jdiscover_changed_paths,
92                 jboolean jinclude_merged_revisions,
93                 jobject jrevprops, jobject jlog_callback);
94     jobject checkPath(jstring jpath, jlong jrevision);
95     jobject stat(jstring jpath, jlong jrevision);
96     jobject getLocations(jstring jpath, jlong jpeg_revision,
97                          jobject jlocation_revisions);
98     void getLocationSegments(jstring jpath, jlong jpeg_revision,
99                              jlong jstart_revision, jlong jend_revision,
100                              jobject jcallback);
101     void getFileRevisions(jstring jpath,
102                           jlong jstart_revision, jlong jend_revision,
103                           jboolean jinclude_merged_revisions,
104                           jobject jcallback);
105     // TODO: lock
106     // TODO: unlock
107     // TODO: getLock
108     jobject getLocks(jstring jpath, jobject jdepth);
109     // TODO: replayRange
110     // TODO: replay
111     // TODO: getDeletedRevision
112     // TODO: getInheritedProperties
113     jboolean hasCapability(jstring capability);
114 
115   private:
116     friend class CommitEditor;
117     RemoteSession(int retryAttempts,
118                   const char* url, const char* uuid,
119                   const char* configDirectory,
120                   const char* username, const char* password,
121                   Prompter::UniquePtr prompter, jobject jcfgcb, jobject jtunnelcb);
122 
123     svn_ra_session_t* m_session;
124     RemoteSessionContext* m_context;
125 };
126 
127 #endif // JAVAHL_REMOTE_SESSION_H
128