~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to vcs/subversion/kdevsvnd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of the KDE Project
3
 
 
4
 
    Copyright (C) 2003, 2004 Mickael Marchand <marchand@kde.org>
5
 
 
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.
9
 
 
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.
14
 
 
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.
19
 
*/
20
 
 
21
 
#include <kapplication.h>
22
 
#include <klocale.h>
23
 
#include <kdebug.h>
24
 
#include <kmessagebox.h>
25
 
#include <kfiledialog.h>
26
 
#include <ktextedit.h>
27
 
#include <kpassdlg.h>
28
 
#include <qdir.h>
29
 
#include <qfile.h>
30
 
 
31
 
#include "config.h"
32
 
 
33
 
#include "kdevsvnd.h"
34
 
 
35
 
#include "kdevsvnd_widgets.h"
36
 
#include "commitdlg.h"
37
 
 
38
 
extern "C" {
39
 
    KDE_EXPORT KDEDModule *create_kdevsvnd(const QCString &name) {
40
 
       return new KDevSvnd(name);
41
 
    }
42
 
}
43
 
 
44
 
KDevSvnd::KDevSvnd(const QCString &name)
45
 
 : KDEDModule(name) {
46
 
}
47
 
KDevSvnd::~KDevSvnd()
48
 
{}
49
 
 
50
 
QString KDevSvnd::commitDialog(QString modifiedFiles) {
51
 
        CommitDlg commitDlg;
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();
57
 
        } else
58
 
                return QString::null;
59
 
}
60
 
int KDevSvnd::sslServerTrustPrompt( QString errmsg, QString hostname, QString fingerPrint, QString validfrom, QString validuntil, QString issuerName, QString ascii_cert )
61
 
{
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 ){
67
 
                return dlg.code();
68
 
        } else{
69
 
                return -1;
70
 
        }
71
 
}
72
 
QString KDevSvnd::sslCertFile()
73
 
{
74
 
        QString fileName = KFileDialog::getOpenFileName(QString::null,QString::null,0, i18n("Open SSL certificate file"));
75
 
        return fileName;
76
 
}
77
 
QCString KDevSvnd::sslPasswdDlg(QString promptMsg)
78
 
{
79
 
        QCString passwd;
80
 
        int ret = KPasswordDialog::getPassword( passwd,promptMsg );
81
 
        if( ret == KPasswordDialog::Accepted ){
82
 
                QCString retstr;
83
 
                retstr.setNum(1);
84
 
                return retstr + passwd;
85
 
        } else{
86
 
                QCString nullstr;
87
 
                nullstr.setNum(-1);
88
 
                return nullstr;
89
 
        }
90
 
}
91
 
 
92
 
 
93
 
// void KDevSvnd::registerMe(const QCString &app)
94
 
// {
95
 
//      insert(app, "test", new TestObject(app));
96
 
//    // When 'app' unregisters with DCOP, the TestObject will get deleted.
97
 
// }
98
 
 
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" ) ) {
104
 
//                      return true;
105
 
//              } else if ( !bdir.exists() ) {
106
 
//                      if ( isFileInSvnEntries( ( *it ).fileName(), ( *it ).directory() + "/.svn/entries" ) || isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
107
 
//                              return true;
108
 
//              }
109
 
//      }
110
 
//      return false;
111
 
// }
112
 
//
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" ) ) {
118
 
//                      return true;
119
 
//              } else if ( !bdir.exists() ) {
120
 
//                      if ( !isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) && !isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
121
 
//                              return true;
122
 
//              }
123
 
//      }
124
 
//      return false;
125
 
// }
126
 
//
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" ) ) {
132
 
//                      return false;
133
 
//              } else if ( !bdir.exists() ) {
134
 
//                      if ( !isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) && !isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" )  )
135
 
//                              return false;
136
 
//              }
137
 
//      }
138
 
//      return true;
139
 
// }
140
 
//
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" ) ) {
146
 
//                      return false;
147
 
//              } else if ( !bdir.exists() ) {
148
 
//                      if ( isFileInSvnEntries( ( *it ).fileName(),( *it ).directory() + "/.svn/entries" ) || isFileInExternals ( ( *it ).fileName(), ( *it ).directory()+"/.svn/dir-props" ) )
149
 
//                              return false;
150
 
//              }
151
 
//      }
152
 
//      return true;
153
 
// }
154
 
//
155
 
// bool KSvnd::isFileInSvnEntries ( const QString filename, const QString entfile ) {
156
 
//      QFile file( entfile );
157
 
//      if ( file.open( IO_ReadOnly ) ) {
158
 
//              QTextStream stream( &file );
159
 
//              QString line;
160
 
//              while ( !stream.atEnd() ) {
161
 
//                      line = stream.readLine().simplifyWhiteSpace();
162
 
//                      if ( line == "name=\""+ filename + "\"" ) {
163
 
//                              file.close();
164
 
//                              return true;
165
 
//                      }
166
 
//              }
167
 
//              file.close();
168
 
//      }
169
 
//      return false;
170
 
// }
171
 
//
172
 
// bool KSvnd::isFileInExternals ( const QString filename, const QString propfile ) {
173
 
//      QFile file( propfile );
174
 
//      if ( file.open( IO_ReadOnly ) ) {
175
 
//              QTextStream stream( &file );
176
 
//              QStringList line;
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
184
 
//                                      i+=2;
185
 
//                                      while ( i < line.count() ) {
186
 
//                                              if ( line[ i ].startsWith( filename+" " ) ) { //found it !
187
 
//                                                      file.close( );
188
 
//                                                      return true;
189
 
//                                              } else if ( line[ i ].isEmpty() ) {
190
 
//                                                      file.close( );
191
 
//                                                      return false; //we are out of svn:externals now...
192
 
//                                              }
193
 
//                                              i++;
194
 
//                                      }
195
 
//                              }
196
 
//                      }
197
 
//              }
198
 
//              file.close();
199
 
//      }
200
 
//      return false;
201
 
// }
202
 
//
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" ) )
208
 
//                      return true;
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" ) )
213
 
//                              result = false;
214
 
//              }
215
 
//
216
 
//              //else check if ./.svn/entries exists
217
 
//              if ( !QFile::exists( ( *it ).directory() + "/.svn/entries" ) )
218
 
//                      result = false;
219
 
//      }
220
 
//      return result;
221
 
// }
222
 
//
223
 
// bool KSvnd::anyValidWorkingCopy( const KURL::List& wclist ) {
224
 
//      for ( QValueListConstIterator<KURL> it = wclist.begin(); it != wclist.end() ; ++it ) {
225
 
//              //skip .svn dirs
226
 
//              if ( ( *it ).path(-1).endsWith( "/.svn" ) )
227
 
//                      continue;
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" ) )
232
 
//                              return true;
233
 
//              }
234
 
//
235
 
//              //else check if ./.svn/entries exists
236
 
//              if ( QFile::exists( ( *it ).directory() + "/.svn/entries" ) )
237
 
//                      return true;
238
 
//      }
239
 
//      return false;
240
 
// }
241
 
//
242
 
// int KSvnd::getStatus( const KURL::List& list ) {
243
 
//      int result = 0;
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 ) ) ) {
247
 
//                      folders++;
248
 
//              } else {
249
 
//                      files++;
250
 
//              }
251
 
//              if ( isFileInSvnEntries ( (*it).filename(),( *it ).directory() + "/.svn/entries" ) ) { // normal subdir known in the working copy
252
 
//                      parentsentries++;
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" ) )
255
 
//                              subdirhavesvn++;
256
 
//                      if ( isFileInExternals( (*it).filename(), ( *it ).directory() + "/.svn/dir-props" ) ) {
257
 
//                              external++;
258
 
//                      }
259
 
//              }
260
 
//              if ( ( isFolder( ( *it ) ) && QFile::exists( ( *it ).directory() + "../.svn/entries" ) ) || QFile::exists( ( *it ).directory() + "/.svn/entries" ) ) //parent has a .svn ?
261
 
//                      parentshavesvn++;
262
 
//      }
263
 
//      if ( files > 0 )
264
 
//              result |= SomeAreFiles;
265
 
//      if ( folders == list.count() ) {
266
 
//              result |= AllAreFolders;
267
 
//              result |= SomeAreFolders;
268
 
//      }
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;
291
 
//
292
 
//      return result;
293
 
// }
294
 
//
295
 
// bool KSvnd::isFolder( const KURL& url ) {
296
 
//      QDir d( url.path() );
297
 
//      return d.exists();
298
 
// }
299
 
//
300
 
// QStringList KSvnd::getActionMenu ( const KURL::List &list ) {
301
 
//      QStringList result;
302
 
//      int listStatus = getStatus( list );
303
 
//
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";
312
 
//              }
313
 
//      } else if ( (listStatus & AllAreInParentsEntries) ) {
314
 
//              result << "Diff";
315
 
//              //In SVN
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";
326
 
//              }
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_";
335
 
//                      result << "Add";
336
 
//              }
337
 
//              result << "_SEPARATOR_";
338
 
//              if( listStatus & SomeAreFiles && !(listStatus & SomeAreFolders)) {
339
 
//                      result << "Blame";
340
 
//              }
341
 
//              result << "CreatePatch";
342
 
//
343
 
//              if( list.size() == 1 && listStatus & SomeAreFolders) {
344
 
// //                   result << "ApplyPatchToFolder";
345
 
//              }
346
 
//      }
347
 
//      return result;
348
 
// }
349
 
//
350
 
// QStringList KSvnd::getTopLevelActionMenu ( const KURL::List &list ) {
351
 
//      QStringList result;
352
 
//      int listStatus = getStatus( list );
353
 
//
354
 
//
355
 
//      if ( ( listStatus & AllParentsHaveSvn &&
356
 
//                      ( ( listStatus & SomeAreExternalToParent ) || ( listStatus & SomeAreInParentsEntries ) )
357
 
//                              || ( listStatus & SomeHaveSvn ) )
358
 
//              ) {
359
 
//              result << "Update";
360
 
//              result << "Commit";
361
 
//      }
362
 
//
363
 
//      return result;
364
 
// }
365
 
//
366
 
// #if 0
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;
370
 
//
371
 
//      QDataStream stream(params, IO_WriteOnly);
372
 
//      stream << path << action << kind << mime_type << content_state << prop_state << revision << userstring;
373
 
//
374
 
//      emitDCOPSignal( "subversionNotify(QString,int,int,QString,int,int,long int,QString)", params );
375
 
// }
376
 
//
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;
381
 
//
382
 
//      QDataStream stream(params, IO_WriteOnly);
383
 
//      stream << path << text_status << prop_status << repos_text_status << repos_prop_status << rev;
384
 
//
385
 
//      emitDCOPSignal( "subversionStatus(QString,int,int,int,int,long int)", params );
386
 
// }
387
 
//
388
 
// void KSvnd::popupMessage( const QString& message ) {
389
 
//      kdDebug(9036) << "KDED/Subversion : popupMessage" << message << endl;
390
 
//      KMessageBox::information(0, message, i18n( "Subversion" ) );
391
 
// }
392
 
// #endif
393
 
 
394
 
#include "kdevsvnd.moc"