summaryrefslogtreecommitdiffstats
path: root/smb4k/core/smb4kerror.cpp
blob: b8bffe13e0e2adfe21805adf1d362428cb4a8566 (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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/***************************************************************************
    smb4kerror  -  This is the class that manages the error messages.
                             -------------------
    begin                : Fr Sep 22 2006
    copyright            : (C) 2006 by Alexander Reinholdt
    email                : dustpuppy@mail.berlios.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                                                    *
 ***************************************************************************/

// KDE includes
#include <kmessagebox.h>
#include <klocale.h>

// application specific includes
#include "smb4kerror.h"
#include "smb4kdefs.h"

void Smb4KError::error( int code, const TQString &text, const TQString &details )
{
  switch ( code )
  {
    case ERROR_GETTING_BROWSELIST:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The browse list could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The browse list could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_GETTING_MEMBERS:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The list of servers could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The list of servers could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_GETTING_SHARES:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The list of shares could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The list of shares could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_GETTING_PREVIEW:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The preview could not be compiled.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The preview could not be compiled.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_OPENING_WALLET_FAILED:
    {
      KMessageBox::error( 0, i18n( "The wallet \"%1\" could not be opened. KWallet support will be disabled for this session." ).tqarg( text ) );

      break;
    }
    case ERROR_GETTING_PERMISSIONS:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "Some file permissions could not be determined.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "Some file permissions could not be determined.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_UNMOUNTING_NOT_ALLOWED:
    {
      KMessageBox::error( 0, i18n( "You are not allowed to unmount this share, because it is owned by another user." ) );

      break;
    }
    case ERROR_MOUNTING_SHARE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The share \"%1\" could not be mounted.\nDetailed information cannot be provided because there was no error message." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be mounted.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_UNMOUNTING_SHARE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The share \"%1\" could not be unmounted.\nDetailed information cannot be provided because there was no error message." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be unmounted.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_FILE_NOT_FOUND:
    {
      KMessageBox::error( 0, i18n( "The file \"%1\" could not be found." ).tqarg( text ) );

      break;
    }
    case ERROR_READING_FILE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The file \"%1\" could not be read." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be read.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_GETTING_HOSTNAME:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The name of your computer could not be determined by using the gethostname() system call.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The name of your computer could not be determined by using the gethostname() system call.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_MISSING_PROGRAMS:
    {
      KMessageBox::error( 0, i18n( "Either your PATH environment variable is not set properly or there are the following programs missing on your system:\n%1\nPlease correct this and restart Smb4K." ).tqarg( text ) );

      break;
    }
    case ERROR_LOCKED:
    {
      KMessageBox::error( 0, i18n( "The file \"%1\" is currently being edited by user %2. To avoid any problems, access to this file is denied at the moment. Please try again later." ).tqarg( text.section( ":", 1, 1 ), text.section( ":", 0, 0 ) ) );

      break;
    }
    case ERROR_MKDIR_FAILED:
    {
      KMessageBox::error( 0, i18n( "The directory \"%1\" could not be created." ).tqarg( text ) );

      break;
    }
    case ERROR_WRITING_FILE:
    {
      KMessageBox::error( 0, i18n( "The file \"%1\" could not be written." ).tqarg( text ) );

      break;
    }
    case ERROR_MOUNTPOINT_EMPTY:
    {
      KMessageBox::error( 0, i18n( "The share could not be unmounted, because the mount point string was empty." ) );

      break;
    }
    case ERROR_FEATURE_NOT_ENABLED:
    {
      KMessageBox::error( 0, i18n( "This feature has not been enabled." ) );

      break;
    }
    case ERROR_BOOKMARK_PRINTER:
    {
      KMessageBox::error( 0, i18n( "Printers cannot be bookmarked." ) );

      break;
    }
    case ERROR_IP_CANNOT_BE_USED:
    {
      KMessageBox::sorry( 0, i18n( "IP addresses are not supported with this search method. Please choose \"Use nmblookup\" in the configuration dialog and try again." ) );

      break;
    }
    case ERROR_IMPORTING_SHARES:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The list of mounted SMBFS and CIFS shares could not be imported.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The list of mounted SMBFS and CIFS shares could not be imported.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_COMMAND_NOT_FOUND:
    {
      KMessageBox::error( 0, i18n( "The command \"%1\" could not be found." ).tqarg( text ) );

      break;
    }
    case ERROR_PRINTING:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The file \"%1\" could not be printed.\nDetailed information cannot be provided because there was no error message." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be printed.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_CREATING_TEMP_DIR:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The temporary directory \"%1\" could not be created.\nDetailed information cannot be provided because there was no error message." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The temporary directory \"%1\" could not be created.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_CREATING_TEMP_FILE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The temporary file \"%1\" could not be created.\nDetailed information cannot be provided because there was no error message." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The temporary file \"%1\" could not be created.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_DIRECTORY_NOT_FOUND:
    {
      KMessageBox::error( 0, i18n( "The directory \"%1\" could not be found." ).tqarg( text ) );

      break;
    }
    case ERROR_FILE_IS_IRREGULAR:
    {
      KMessageBox::error( 0, i18n( "The file \"%1\" is irregular. That means it is either a symlink, a fifo, or something similar. This could indicate that someone is trying to exploit your system. Please inform your system administrator." ).tqarg( text ) );

      break;
    }
    case ERROR_SYNCHRONIZING:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The synchronization could not the accomplished successfully.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The synchronization could not the accomplished successfully.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_OPENING_FILE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The file \"%1\" could not be opened." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be opened.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_CLOSING_FILE:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The file \"%1\" could not be closed." ).tqarg( text ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be closed.\nRead the error message under \"Details\" to find out more." ).tqarg( text ), details );
      }

      break;
    }
    case ERROR_NET_COMMAND:
    {
      KMessageBox::error( 0, i18n( "The list of arguments for the \"net\" command could not be assembled.\nAt the moment it reads: %1" ).tqarg( text ) );

      break;
    }
    case ERROR_GETTING_GIDS:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "The list of supplementary group IDs could not be determined." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "The list of supplementary group IDs could not be determined.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
    case ERROR_UNKNOWN:
    default:
    {
      if ( details.stripWhiteSpace().isEmpty() )
      {
        KMessageBox::error( 0, i18n( "An unknown error occurred.\nDetailed information cannot be provided because there was no error message." ) );
      }
      else
      {
        KMessageBox::detailedError( 0, i18n( "An unknown error occurred.\nRead the error message under \"Details\" to find out more." ), details );
      }

      break;
    }
  }
}


int Smb4KError::warning( int code, const TQString &, const TQString & )
{
  switch ( code )
  {
    default:
    {
      return 0;
    }
  }
}


void Smb4KError::information( int code, const TQString &text, const TQString &details )
{
  switch ( code )
  {
    case INFO_MIMETYPE_NOT_SUPPORTED:
    {
      KMessageBox::information( 0, i18n( "The mimetype \"%1\" is not supported. Please convert the file to PostScript or PDF." ).tqarg( text ) );

      break;
    }
    case INFO_DISABLE_SUID_FEATURE:
    {
      KMessageBox::information( 0, i18n( "You previously chose to use \"%1\", but now it is missing on your system. Smb4K will disable this feature." ).tqarg( text ) );

      break;
    }
    case INFO_BOOKMARK_LABEL_IN_USE:
    {
      KMessageBox::information( 0, i18n( "The label \"%1\" is used more than once. It will automatically be renamed for bookmark \"%2\" to avoid confusion." ).tqarg( text, details ) );

      break;
    }
    default:
    {
      break;
    }
  }
}

// No tqmoc file needs to be included