2
This file is part of the KDE Project
4
Copyright (C) 2003, 2004 Mickael Marchand <marchand@kde.org>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
version 2 as published by the Free Software Foundation.
10
This software is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this library; see the file COPYING. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include <kapplication.h>
24
#include <kmessagebox.h>
25
#include <kfiledialog.h>
26
#include <ktextedit.h>
35
#include "kdevsvnd_widgets.h"
36
#include "commitdlg.h"
39
KDE_EXPORT KDEDModule *create_kdevsvnd(const QCString &name) {
40
return new KDevSvnd(name);
44
KDevSvnd::KDevSvnd(const QCString &name)
50
QString KDevSvnd::commitDialog(QString modifiedFiles) {
52
commitDlg.setCaption(i18n("Enter Commit Log Message:"));
53
commitDlg.listMessage->setText( modifiedFiles );
54
int result = commitDlg.exec();
55
if ( result == QDialog::Accepted ) {
56
return commitDlg.textMessage->text();
60
int KDevSvnd::sslServerTrustPrompt( QString errmsg, QString hostname, QString fingerPrint, QString validfrom, QString validuntil, QString issuerName, QString ascii_cert )
62
SvnSSLTrustPrompt dlg;
63
dlg.setupCertInfo( hostname, fingerPrint, validfrom, validuntil, issuerName, ascii_cert );
64
dlg.setupFailedReasonMsg( errmsg );
65
int result = dlg.exec();
66
if ( result == QDialog::Accepted ){
72
QString KDevSvnd::sslCertFile()
74
QString fileName = KFileDialog::getOpenFileName(QString::null,QString::null,0, i18n("Open SSL certificate file"));
77
QCString KDevSvnd::sslPasswdDlg(QString promptMsg)
80
int ret = KPasswordDialog::getPassword( passwd,promptMsg );
81
if( ret == KPasswordDialog::Accepted ){
84
return retstr + passwd;
93
// void KDevSvnd::registerMe(const QCString &app)
95
// insert(app, "test", new TestObject(app));
96
// // When 'app' unregisters with DCOP, the TestObject will get deleted.
99
// bool KSvnd::AreAnyFilesInSvn( const KURL::List& wclist ) {
100
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
101
// kdDebug( 9036 ) << "Checking file " << ( *it ) << endl;
102
// QDir bdir ( ( *it ).path() );
103
// if ( bdir.exists() && QFile::exists( ( *it ).path() + "/.svn/entries" ) ) {
105
// } else if ( !bdir.exists() ) {
106
// if ( isFileInSvnEntries( ( *it ).fileName(), ( *it ).directory() + "/.svn/entries" ) || isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
113
// bool KSvnd::AreAnyFilesNotInSvn( const KURL::List& wclist ) {
114
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
115
// kdDebug( 9036 ) << "Checking file " << ( *it ) << endl;
116
// QDir bdir ( ( *it ).path() );
117
// if ( bdir.exists() && !QFile::exists( ( *it ).path() + "/.svn/entries" ) ) {
119
// } else if ( !bdir.exists() ) {
120
// if ( !isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) && !isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
127
// bool KSvnd::AreAllFilesInSvn( const KURL::List& wclist ) {
128
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
129
// kdDebug( 9036 ) << "Checking file " << ( *it ) << endl;
130
// QDir bdir ( ( *it ).path() );
131
// if ( bdir.exists() && !QFile::exists( ( *it ).path() + "/.svn/entries" ) ) {
133
// } else if ( !bdir.exists() ) {
134
// if ( !isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) && !isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
141
// bool KSvnd::AreAllFilesNotInSvn( const KURL::List& wclist ) {
142
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
143
// kdDebug( 9036 ) << "Checking file " << ( *it ) << endl;
144
// QDir bdir ( ( *it ).path() );
145
// if ( bdir.exists() && QFile::exists( ( *it ).path() + "/.svn/entries" ) ) {
147
// } else if ( !bdir.exists() ) {
148
// if ( isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) || isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
155
// bool KSvnd::isFileInSvnEntries ( const QString filename, const QString entfile ) {
156
// QFile file( entfile );
157
// if ( file.open( IO_ReadOnly ) ) {
158
// QTextStream stream( &file );
160
// while ( !stream.atEnd() ) {
161
// line = stream.readLine().simplifyWhiteSpace();
162
// if ( line == "name=\""+ filename + "\"" ) {
172
// bool KSvnd::isFileInExternals ( const QString filename, const QString propfile ) {
173
// QFile file( propfile );
174
// if ( file.open( IO_ReadOnly ) ) {
175
// QTextStream stream( &file );
177
// while ( !stream.atEnd() )
178
// line << stream.readLine().simplifyWhiteSpace();
179
// for ( uint i = 0 ; i < line.count(); i++ ) {
180
// if ( line[ i ] == "K 13" && line[ i+1 ] == "svn:externals" ) { //Key 13 : svn:externals
181
// //next line should be "V xx"
182
// if ( line [ i+2 ].startsWith( "V " ) ) {
183
// //ok browse the values now
185
// while ( i < line.count() ) {
186
// if ( line[ i ].startsWith( filename+" " ) ) { //found it !
189
// } else if ( line[ i ].isEmpty() ) {
191
// return false; //we are out of svn:externals now...
203
// bool KSvnd::anyNotValidWorkingCopy( const KURL::List& wclist ) {
204
// bool result = true; //one negative match is enough
205
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
206
// //exception for .svn dirs
207
// if ( ( *it ).path(-1).endsWith( "/.svn" ) )
209
// //if is a directory check whether it contains a .svn/entries file
210
// QDir dir( ( *it ).path() );
211
// if ( dir.exists() ) { //it's a dir
212
// if ( !QFile::exists( ( *it ).path() + "/.svn/entries" ) )
216
// //else check if ./.svn/entries exists
217
// if ( !QFile::exists( ( *it ).directory() + "/.svn/entries" ) )
223
// bool KSvnd::anyValidWorkingCopy( const KURL::List& wclist ) {
224
// for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
226
// if ( ( *it ).path(-1).endsWith( "/.svn" ) )
228
// //if is a directory check whether it contains a .svn/entries file
229
// QDir dir( ( *it ).path() );
230
// if ( dir.exists() ) { //it's a dir
231
// if ( QFile::exists( ( *it ).path() + "/.svn/entries" ) )
235
// //else check if ./.svn/entries exists
236
// if ( QFile::exists( ( *it ).directory() + "/.svn/entries" ) )
242
// int KSvnd::getStatus( const KURL::List& list ) {
244
// uint files = 0, folders = 0, parentsentries = 0, parentshavesvn = 0, subdirhavesvn = 0, external = 0;
245
// for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) {
246
// if ( isFolder ( ( *it ) ) ) {
251
// if ( isFileInSvnEntries ( (*it).filename(),( *it ).directory() + "/.svn/entries" ) ) { // normal subdir known in the working copy
253
// } else if ( isFolder( *it ) ) { // other subfolders (either another module checkouted or an external, or something not known at all)
254
// if ( QFile::exists( ( *it ).path() + "/.svn/entries" ) )
256
// if ( isFileInExternals( (*it).filename(), ( *it ).directory() + "/.svn/dir-props" ) ) {
260
// if ( ( isFolder( ( *it ) ) && QFile::exists( ( *it ).directory() + "../.svn/entries" ) ) || QFile::exists( ( *it ).directory() + "/.svn/entries" ) ) //parent has a .svn ?
264
// result |= SomeAreFiles;
265
// if ( folders == list.count() ) {
266
// result |= AllAreFolders;
267
// result |= SomeAreFolders;
269
// if ( folders > 0 )
270
// result |= SomeAreFolders;
271
// if ( parentsentries == list.count() ) {
272
// result |= AllAreInParentsEntries;
273
// result |= SomeAreInParentsEntries;
274
// } else if ( parentsentries != 0 )
275
// result |= SomeAreInParentsEntries;
276
// if ( parentshavesvn == list.count() ) {
277
// result |= AllParentsHaveSvn;
278
// result |= SomeParentsHaveSvn;
279
// } else if ( parentshavesvn > 0 )
280
// result |= SomeParentsHaveSvn;
281
// if ( subdirhavesvn == list.count() ) {
282
// result |= AllHaveSvn;
283
// result |= SomeHaveSvn;
284
// } else if ( subdirhavesvn > 0 )
285
// result |= SomeHaveSvn;
286
// if ( external == list.count() ) {
287
// result |= AllAreExternalToParent;
288
// result |= SomeAreExternalToParent;
289
// } else if ( external > 0 )
290
// result |= SomeAreExternalToParent;
295
// bool KSvnd::isFolder( const KURL& url ) {
296
// QDir d( url.path() );
297
// return d.exists();
300
// QStringList KSvnd::getActionMenu ( const KURL::List &list ) {
301
// QStringList result;
302
// int listStatus = getStatus( list );
304
// if ( !(listStatus & SomeAreInParentsEntries) &&
305
// !(listStatus & SomeAreExternalToParent) &&
306
// !(listStatus & SomeHaveSvn)) {
307
// if( list.size() == 1 && listStatus & SomeAreFolders) {
308
// result << "Checkout";
309
// result << "Export";
310
// // result << "CreateRepository";
311
// result << "Import";
313
// } else if ( (listStatus & AllAreInParentsEntries) ) {
316
// // result << "ShowLog";
317
// // result << "CheckForModifications";
318
// // result << "RevisionGraph";
319
// // result << "_SEPARATOR_";
320
// // result << "Update to revision..."
321
// result << "Rename";
322
// result << "Delete";
323
// if( listStatus & SomeAreFolders && !(listStatus & SomeAreFiles)) {
324
// result << "Revert";
325
// // result << "Cleanup";
327
// result << "_SEPARATOR_";
328
// // result << "BranchTag";
329
// result << "Switch";
330
// result << "Merge";
331
// if( listStatus & SomeAreFolders && !(listStatus & SomeAreFiles)) {
332
// // result << "Export";
333
// // result << "Relocate";
334
// result << "_SEPARATOR_";
337
// result << "_SEPARATOR_";
338
// if( listStatus & SomeAreFiles && !(listStatus & SomeAreFolders)) {
339
// result << "Blame";
341
// result << "CreatePatch";
343
// if( list.size() == 1 && listStatus & SomeAreFolders) {
344
// // result << "ApplyPatchToFolder";
350
// QStringList KSvnd::getTopLevelActionMenu ( const KURL::List &list ) {
351
// QStringList result;
352
// int listStatus = getStatus( list );
355
// if ( ( listStatus & AllParentsHaveSvn &&
356
// ( ( listStatus & SomeAreExternalToParent ) || ( listStatus & SomeAreInParentsEntries ) )
357
// || ( listStatus & SomeHaveSvn ) )
359
// result << "Update";
360
// result << "Commit";
367
// void KSvnd::notify(const QString& path, int action, int kind, const QString& mime_type, int content_state, int prop_state, long int revision, const QString& userstring) {
368
// kdDebug(9036) << "KDED/Subversion : notify " << path << " action : " << action << " mime_type : " << mime_type << " content_state : " << content_state << " prop_state : " << prop_state << " revision : " << revision << " userstring : " << userstring << endl;
369
// QByteArray params;
371
// QDataStream stream(params, IO_WriteOnly);
372
// stream << path << action << kind << mime_type << content_state << prop_state << revision << userstring;
374
// emitDCOPSignal( "subversionNotify(QString,int,int,QString,int,int,long int,QString)", params );
377
// void KSvnd::status(const QString& path, int text_status, int prop_status, int repos_text_status, int repos_prop_status, long int rev ) {
378
// kdDebug(9036) << "KDED/Subversion : status " << path << " " << text_status << " " << prop_status << " "
379
// << repos_text_status << " " << repos_prop_status << " " << rev << endl;
380
// QByteArray params;
382
// QDataStream stream(params, IO_WriteOnly);
383
// stream << path << text_status << prop_status << repos_text_status << repos_prop_status << rev;
385
// emitDCOPSignal( "subversionStatus(QString,int,int,int,int,long int)", params );
388
// void KSvnd::popupMessage( const QString& message ) {
389
// kdDebug(9036) << "KDED/Subversion : popupMessage" << message << endl;
390
// KMessageBox::information(0, message, i18n( "Subversion" ) );
394
#include "kdevsvnd.moc"