summaryrefslogtreecommitdiffstats
path: root/src/svnfrontend/svnactions.h
blob: ded84773fbd25c4aeb555ca98cf70530c9c85f52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/***************************************************************************
 *   Copyright (C) 2005-2007 by Rajko Albrecht                             *
 *   ral@alwins-world.de                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#ifndef SVNACTIONS_H
#define SVNACTIONS_H

#include "client.hpp"
#include "revision.hpp"
#include "smart_pointer.hpp"
#include "shared_pointer.hpp"
#include "svnqttypes.hpp"

#include "simple_logcb.h"

#include <kurl.h>
#include <kguiitem.h>

#include <tqobject.h>
#include <tqdatetime.h>
#include <tqstringlist.h>

class ItemDisplay;
class SvnItem;
class KDialog;
class KDialogBase;
class TQDialog;
class CContextListener;
class KProcess;
class SvnActionsData;
class CheckModifiedThread;
class CheckUpdatesThread;
class FillCacheThread;

namespace svn {
    class Context;
    class LogEntry;
    class InfoEntry;
}

namespace KIO {
    class Job;
}

/**
@author Rajko Albrecht
*/
class SvnActions : public TQObject,public SimpleLogCb
{
    Q_OBJECT
  
public:
    enum ThreadType {
        checkupdatethread,
        fillcachethread,
        checkmodifiedthread
    };

    SvnActions(ItemDisplay *parent, const char *name = 0,bool processes_blocked=false);
    ~SvnActions();
    void reInitClient();
    //svn::Client&svnClient(){return m_Svnclient;}
    svn::Client* svnclient();
    void prepareUpdate(bool ask);
    template<class T> KDialogBase* createDialog(T**ptr,const TQString&_head,bool OkCance=false,
            const char*name="standard_dialog",
            bool showHelp=false,bool modal=true,
            const KGuiItem&u1 = KGuiItem());

    bool makeGet(const svn::Revision&start, const TQString&what,const TQString&target,
        const svn::Revision&peg=svn::Revision::UNDEFINED,TQWidget*dlgparent=0);


    bool addItems(const TQValueList<svn::Path> &items,svn::Depth depth=svn::DepthEmpty);
    bool addItems(const TQStringList&w,svn::Depth depth=svn::DepthEmpty);
    void checkAddItems(const TQString&path,bool print_error_box=true);

    bool makeDelete(const svn::Pathes&);
    bool makeDelete(const TQStringList&);
    void makeLock(const TQStringList&,const TQString&,bool);
    void makeUnlock(const TQStringList&,bool);

    bool makeStatus(const TQString&what, svn::StatusEntries&dlist, svn::Revision&where, bool rec=false,bool all=true);
    bool makeStatus(const TQString&what, svn::StatusEntries&dlist, svn::Revision&where, bool rec,bool all,bool display_ignored,bool updates=false);
    bool makeList(const TQString&url,svn::DirEntries&dlist,svn::Revision&where,bool rec=false);

    bool createModifiedCache(const TQString&base);
    bool checkModifiedCache(const TQString&path);
    bool checkConflictedCache(const TQString&path);
    bool checkReposLockCache(const TQString&path);
    bool checkReposLockCache(const TQString&path,svn::SharedPointer<svn::Status>&t);
    void addModifiedCache(const svn::StatusPtr&what);
    void deleteFromModifiedCache(const TQString&what);

    bool makeIgnoreEntry(SvnItem*which,bool unignore);
    bool isLockNeeded(SvnItem*which,const svn::Revision&where);
    TQString searchProperty(TQString&store, const TQString&property, const TQString&start,const svn::Revision&where,bool up=false);
    svn::PathPropertiesMapListPtr propList(const TQString&which,const svn::Revision&where,bool cacheOnly);

    bool changeProperties(const svn::PropertiesMap&setList,const TQValueList<TQString>&,const TQString&path);

    //! generate and displays a revision tree
    /*!
     * the parameter @a what must prepared, eg, if it comes from working copy
     * it must not contain a "file://" inside.
     * \param what item to display
     * \param rev Revision the item-path is available, intersting only when @a what is a repository item
     * \param startr startrevision for log
     * \param endr endrevision for log
     */
    void makeTree(const TQString&what,const svn::Revision&rev,
        const svn::Revision&startr=svn::Revision(1),
        const svn::Revision&endr=svn::Revision::HEAD);
    void makeLog(const svn::Revision&start,const svn::Revision&end,const svn::Revision&peg,SvnItem*k,bool list_files=false,int limit = 0);
    void makeLog(const svn::Revision&start,const svn::Revision&end,const svn::Revision&peg,const TQString&,bool list_files=false, int limit=0);
    svn::SharedPointer<svn::LogEntriesMap> getLog(const svn::Revision&start,const svn::Revision& end,const svn::Revision&peg,const TQString&,bool list_files, int limit,TQWidget*parent=0);
    virtual bool getSingleLog(svn::LogEntry&,const svn::Revision&,const TQString&,const svn::Revision&,TQString&root);

    void makeBlame(const svn::Revision&start, const svn::Revision&end, SvnItem*k);
    void makeBlame(const svn::Revision&start, const svn::Revision&end, const TQString&,TQWidget*parent=0,const svn::Revision&peg=svn::Revision::UNDEFINED,SimpleLogCb*_acb=0);
    void makeUpdate(const TQStringList&what,const svn::Revision&rev,bool recurse);
    bool makeSwitch(const TQString&rUrl,const TQString&tPath,const svn::Revision&r,svn::Depth depth,const svn::Revision&peg,bool stickydepth,bool ignore_externals,bool allow_unversioned);
    bool makeSwitch(const TQString&path,const TQString&what);
    bool makeRelocate(const TQString&fUrl,const TQString&tUrl,const TQString&path,bool rec = true);
    bool makeCheckout(const TQString&,const TQString&,const svn::Revision&,const svn::Revision&,svn::Depth,bool isExport,bool openit,bool ignore_externals,bool overwrite,TQWidget*p);
    void makeInfo(TQPtrList<SvnItem> lst,const svn::Revision&,const svn::Revision&,bool recursive = true);
    void makeInfo(const TQStringList&lst,const svn::Revision&,const svn::Revision&,bool recursive = true);
    bool makeCommit(const svn::Targets&);
    void CheckoutExport(const TQString&what,bool _exp,bool urlisTarget=false);

    TQString getInfo(TQPtrList<SvnItem> lst,const svn::Revision&rev,const svn::Revision&peg,bool recursive,bool all=true);
    TQString getInfo(const TQString&_what,const svn::Revision&rev,const svn::Revision&peg,bool recursive,bool all=true);

    TQString makeMkdir(const TQString&);
    bool makeMkdir(const TQStringList&,const TQString&);
    bool isLocalWorkingCopy(const KURL&url,TQString&_baseUri);
    bool createUpdateCache(const TQString&what);
    bool checkUpdateCache(const TQString&path)const;
    bool isUpdated(const TQString&path)const;
    bool getUpdated(const TQString&path,svn::SharedPointer<svn::Status>&d)const;
    void clearUpdateCache();
    void removeFromUpdateCache(const TQStringList&what,bool exact_only);
    void stopCheckModThread();
    void stopCheckUpdateThread();
    void startFillCache(const TQString&path);
    void stopFillCache();
    void stopMain();
    void killallThreads();

    bool checkUpdatesRunning();
    void getaddedItems(const TQString&path,svn::StatusEntries&target);

    bool makeCopy(const TQString&,const TQString&,const svn::Revision&rev);
    bool makeCopy(const KURL::List&,const TQString&,const svn::Revision&rev);

    bool makeMove(const TQString&,const TQString&,bool);
    bool makeMove(const KURL::List&,const TQString&,bool);

    virtual bool makeCleanup(const TQString&);

    bool get(const TQString&what,const TQString& to,const svn::Revision&rev,const svn::Revision&peg,TQWidget*p);
    bool singleInfo(const TQString&what,const svn::Revision&rev,svn::InfoEntry&target,const svn::Revision&_peg=svn::Revision::UNDEFINED);

    void setContextData(const TQString&,const TQString&);
    void clearContextData();
    TQString getContextData(const TQString&)const;

    bool threadRunning(ThreadType which);

    virtual void customEvent ( TQCustomEvent * e );

    bool doNetworking();

protected:
    svn::smart_pointer<SvnActionsData> m_Data;

    void CheckoutExport(bool _exp);
    void CheckoutExportCurrent(bool _exp);
    void makeAdd(bool rec);
    CheckModifiedThread*m_CThread,*m_UThread;
    FillCacheThread*m_FCThread;
    void makeDiffinternal(const TQString&,const svn::Revision&,const TQString&,const svn::Revision&,TQWidget*,const svn::Revision&peg=svn::Revision::UNDEFINED);
    void makeDiffExternal(const TQString&p1,const svn::Revision&start,const TQString&p2,const svn::Revision&end,const svn::Revision&_peg,bool isDir,TQWidget*p,bool rec=true);

public slots:
    virtual void dispDiff(const TQByteArray&);
    virtual void slotProperties();
    virtual void slotNotifyMessage(const TQString&);
    virtual void slotCommit();
    virtual void slotUpdateHeadRec();
    virtual void slotUpdateTo();
    virtual void slotAdd();
    virtual void slotAddRec();
    virtual void slotCheckoutCurrent();
    virtual void slotExportCurrent();
    virtual void slotCheckout();
    virtual void slotExport();
    virtual void slotRevert();
    virtual void slotRevertItems(const TQStringList&);
    virtual void slotSwitch();
    virtual void slotResolved(const TQString&);
    virtual void slotResolve(const TQString&);
    virtual void makeDiff(const TQString&,const svn::Revision&,const svn::Revision&,const svn::Revision&_peg,bool isDir);
    virtual void makeDiff(const TQString&,const svn::Revision&,const TQString&,const svn::Revision&);
    virtual void makeDiff(const TQString&,const svn::Revision&,const TQString&,const svn::Revision&,const svn::Revision&,bool,TQWidget*p);
    virtual void makeDiff(const TQString&,const svn::Revision&,const TQString&,const svn::Revision&,TQWidget*);
    virtual void makeNorecDiff(const TQString&,const svn::Revision&,const TQString&,const svn::Revision&,TQWidget*);
    virtual void slotImport(const TQString&,const TQString&,const TQString&,svn::Depth,bool noIgnore,bool noUnknown);
    virtual void slotMergeWcRevisions(const TQString&,const svn::Revision&,const svn::Revision&,bool,bool,bool,bool);
    virtual void slotMerge(const TQString&,const TQString&, const TQString&,
                            const svn::Revision&,const svn::Revision&,const svn::Revision&,
                            bool,bool,bool,bool);
    virtual void slotMergeExternal(const TQString&src1,const TQString&src2, const TQString&target,
                                    const svn::Revision&rev1,const svn::Revision&rev2,const svn::Revision&_peg,bool);
    virtual void slotExtraLogMsg(const TQString&);
    virtual void slotMakeCat(const svn::Revision&start, const TQString&what,const TQString&disp,const svn::Revision&peg,TQWidget*dlgparent);

    virtual void slotCancel(bool);

signals:
    void clientException(const TQString&);
    void sendNotify(const TQString&);
    void reinitItem(SvnItem*);
    void sigRefreshAll();
    void sigThreadsChanged();
    void sigRefreshCurrent(SvnItem*);
    void sigRefreshIcons(bool);
    void sigExtraLogMsg(const TQString&);
    void sigGotourl(const TQString&);
    void sigCacheStatus(TQ_LONG,TQ_LONG);

protected slots:
    virtual void wroteStdin(KProcess*);
    virtual void procClosed(KProcess*);
    virtual void checkModthread();
    virtual void checkUpdateThread();
    virtual void receivedStderr(KProcess*,char*,int);
};

#endif