1
/***************************************************************************
2
smb4kcoremessage - This class provides messages for use with the
6
copyright : (C) 2008 by Alexander Reinholdt
7
email : dustpuppy@users.berlios.de
8
***************************************************************************/
10
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
* This program is distributed in the hope that it will be useful, but *
17
* WITHOUT ANY WARRANTY; without even the implied warranty of *
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19
* General Public License for more details. *
21
* You should have received a copy of the GNU General Public License *
22
* along with this program; if not, write to the *
23
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
25
***************************************************************************/
28
#include <QDesktopWidget>
31
#include <kmessagebox.h>
33
#include <kapplication.h>
35
// application specific includes
36
#include "smb4kcoremessage.h"
39
void Smb4KCoreMessage::error( int code, const QString &text, const QString &details )
45
if ( kapp->activeWindow() )
47
parent = kapp->activeWindow();
51
parent = kapp->desktop();
61
case ERROR_GETTING_WORKGROUPS:
63
if ( details.trimmed().isEmpty() )
65
KMessageBox::error( parent, i18n( "<qt><p>The list of workgroups and domains could not be retrieved.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
69
KMessageBox::detailedError( parent, i18n( "<qt><p>The list of workgroups and domains could not be retrieved.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
74
case ERROR_PERFORMING_IPSCAN:
76
if ( details.trimmed().isEmpty() )
78
KMessageBox::error( parent, i18n( "<qt><p>The list of registered IP addresses within the given broadcast areas could not be retrieved.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
82
KMessageBox::detailedError( parent, i18n( "<qt><p>The list of registered IP addresses within the given broadcast areas could not be retrieved.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
87
case ERROR_GETTING_MEMBERS:
89
if ( details.trimmed().isEmpty() )
91
KMessageBox::error( parent, i18n( "<qt><p>The list of servers could not be retrieved.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
95
KMessageBox::detailedError( parent, i18n( "<qt><p>The list of servers could not be retrieved.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
100
case ERROR_GETTING_SHARES:
102
if ( details.trimmed().isEmpty() )
104
KMessageBox::error( parent, i18n( "<qt><p>The list of shares could not be retrieved.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
108
KMessageBox::detailedError( parent, i18n( "<qt><p>The list of shares could not be retrieved.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
113
case ERROR_GETTING_PREVIEW:
115
if ( details.trimmed().isEmpty() )
117
KMessageBox::error( parent, i18n( "<qt><p>The preview could not be compiled.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
121
KMessageBox::detailedError( parent, i18n( "<qt><p>The preview could not be compiled.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
126
case ERROR_UNMOUNTING_NOT_ALLOWED:
128
KMessageBox::error( parent, i18n( "<qt>You are not allowed to unmount this share. It is owned by another user.</qt>" ) );
132
case ERROR_MOUNTING_SHARE:
134
if ( details.trimmed().isEmpty() )
136
KMessageBox::error( parent, i18n( "<qt><p>The share \"%1\" could not be mounted.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ).arg( text ) );
140
KMessageBox::detailedError( parent, i18n( "<qt><p>The share \"%1\" could not be mounted.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
145
case ERROR_UNMOUNTING_SHARE:
147
if ( details.trimmed().isEmpty() )
149
KMessageBox::error( parent, i18n( "<qt><p>The share \"%1\" could not be unmounted.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ).arg( text ) );
153
KMessageBox::detailedError( parent, i18n( "<qt><p>The share \"%1\" could not be unmounted.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
158
case ERROR_FILE_NOT_FOUND:
160
KMessageBox::error( parent, i18n( "<qt>The file \"%1\" could not be found.</qt>" ).arg( text ) );
164
case ERROR_GETTING_HOSTNAME:
166
if ( details.trimmed().isEmpty() )
168
KMessageBox::error( parent, i18n( "<qt><p>The name of your computer could not be determined by using the gethostname() system call.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
172
KMessageBox::detailedError( parent, i18n( "<qt><p>The name of your computer could not be determined by using the gethostname() system call.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
177
case ERROR_MISSING_PROGRAMS:
179
KMessageBox::error( parent, i18n( "<qt><p>Either your PATH environment variable is not set properly or there are the following programs missing on your system:</p><p>%1</p><p>Please correct this and restart Smb4K.</p></qt>" ).arg( text ) );
183
case ERROR_MKDIR_FAILED:
185
KMessageBox::error( parent, i18n( "<qt>The directory \"%1\" could not be created.</qt>" ).arg( text ) );
189
case ERROR_MOUNTPOINT_EMPTY:
191
KMessageBox::error( parent, i18n( "<qt>The share could not be unmounted, because the mount point string was empty.</qt>" ) );
195
case ERROR_FEATURE_NOT_ENABLED:
197
KMessageBox::error( parent, i18n( "<qt>This feature has not been enabled.</qt>" ) );
201
case ERROR_BOOKMARK_PRINTER:
203
KMessageBox::error( parent, i18n( "<qt>Printers cannot be bookmarked.</qt>" ) );
207
case ERROR_SUDOWRITER:
209
if ( details.trimmed().isEmpty() )
211
KMessageBox::error( parent, i18n( "<qt><p>An error occurred while writing to the sudoers file.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
215
KMessageBox::detailedError( parent, i18n( "<qt><p>An error occurred while writing to the sudoers file.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
220
case ERROR_IMPORTING_SHARES:
222
if ( details.trimmed().isEmpty() )
224
KMessageBox::error( parent, i18n( "<qt><p>The list of mounted shares could not be imported.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
228
KMessageBox::detailedError( parent, i18n( "<qt><p>The list of mounted shares could not be imported.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
233
case ERROR_COMMAND_NOT_FOUND:
235
KMessageBox::error( parent, i18n( "<qt>The command \"%1\" could not be found.</qt>" ).arg( text ) );
241
if ( details.trimmed().isEmpty() )
243
KMessageBox::error( parent, i18n( "<qt><p>The file \"%1\" could not be printed.</p></p>Detailed information cannot be provided because there was no error message.</p></qt>" ).arg( text ) );
247
KMessageBox::detailedError( parent, i18n( "<qt><p>The file \"%1\" could not be printed.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
252
case ERROR_CREATING_TEMP_DIR:
254
if ( details.trimmed().isEmpty() )
256
KMessageBox::error( parent, i18n( "<qt><p>The temporary directory \"%1\" could not be created.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ).arg( text ) );
260
KMessageBox::detailedError( parent, i18n( "<qt><p>The temporary directory \"%1\" could not be created.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
265
case ERROR_SYNCHRONIZING:
267
if ( details.trimmed().isEmpty() )
269
KMessageBox::error( parent, i18n( "<qt></p>The synchronization could not be finished successfully.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
273
KMessageBox::detailedError( parent, i18n( "<qt><p>The synchronization could not be finished successfully.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
278
case ERROR_SEARCHING:
280
if ( details.trimmed().isEmpty() )
282
KMessageBox::error( parent, i18n( "<qt><p>The search could not be finished successfully.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
286
KMessageBox::detailedError( parent, i18n( "<qt><p>The search could not be finished successfully.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
291
case ERROR_OPENING_FILE:
293
if ( details.trimmed().isEmpty() )
295
KMessageBox::error( parent, i18n( "<qt>The file \"%1\" could not be opened.</qt>" ).arg( text ) );
299
KMessageBox::detailedError( parent, i18n( "<qt><p>The file \"%1\" could not be opened.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
304
case ERROR_NET_COMMAND:
306
KMessageBox::error( parent, i18n( "<qt>The list of arguments for the \"net\" command could not be assembled.</qt>" ) );
310
case ERROR_XML_ERROR:
312
if ( details.trimmed().isEmpty() )
314
KMessageBox::error( parent, i18n( "<qt><p>An error occurred while parsing the XML file \"%1\".</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ).arg( text ) );
318
KMessageBox::detailedError( parent, i18n( "<qt><p>An error occurred while parsing the XML file \"%1\".</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ).arg( text ), details );
326
if ( details.trimmed().isEmpty() )
328
KMessageBox::error( parent, i18n( "<qt><p>An unknown error occurred.</p><p>Detailed information cannot be provided because there was no error message.</p></qt>" ) );
332
KMessageBox::detailedError( parent, i18n( "<qt><p>An unknown error occurred.</p><p>Read the error message under \"Details\" to find out more.</p></qt>" ), details );
341
void Smb4KCoreMessage::processError( int code, QProcess::ProcessError error )
347
if ( kapp->activeWindow() )
349
parent = kapp->activeWindow();
353
parent = kapp->desktop();
363
case ERROR_PROCESS_ERROR:
367
case QProcess::FailedToStart:
369
KMessageBox::error( parent, i18n( "<qt>The process failed to start (error code: %1).</qt>" ).arg( error ) );
373
case QProcess::Crashed:
375
KMessageBox::error( parent, i18n( "<qt>The process crashed (error code: %1).</qt>" ).arg( error ) );
379
case QProcess::Timedout:
381
KMessageBox::error( parent, i18n( "<qt>The process timed out (error code: %1).</qt>" ).arg( error ) );
385
case QProcess::WriteError:
387
KMessageBox::error( parent, i18n( "<qt>Could not write to the process (error code: %1).</qt>" ).arg( error ) );
391
case QProcess::ReadError:
393
KMessageBox::error( parent, i18n( "<qt>Could not read from the process (error code: %1).</qt>" ).arg( error ) );
397
case QProcess::UnknownError:
400
KMessageBox::error( parent, i18n( "<qt>The process reported an unknown error.</qt>" ) );
408
case ERROR_PROCESS_EXIT:
410
KMessageBox::error( parent, i18n( "<qt>The process exited unexpectedly.</qt>" ) );
422
int Smb4KCoreMessage::warning( int code, const QString &/*text*/, const QString &/*details*/ )
428
if ( kapp->activeWindow() )
430
parent = kapp->activeWindow();
434
parent = kapp->desktop();
456
void Smb4KCoreMessage::information( int code, const QString &text, const QString &details )
462
if ( kapp->activeWindow() )
464
parent = kapp->activeWindow();
468
parent = kapp->desktop();
478
case INFO_MIMETYPE_NOT_SUPPORTED:
480
KMessageBox::information( parent, i18n( "<qt>The mimetype \"%1\" is not supported. Please convert the file to PostScript or PDF.</qt>" ).arg( text ) );
484
case INFO_DISABLE_SUID_FEATURE:
486
KMessageBox::information( parent, i18n( "<qt>You previously chose to use \"%1\", but now it is missing on your system. Smb4K will disable this feature.</qt>" ).arg( text ) );
490
case INFO_BOOKMARK_LABEL_IN_USE:
492
KMessageBox::information( parent, i18n( "<qt>The label \"%1\" is used more than once. It will automatically be renamed for bookmark \"%2\" to avoid confusion.</qt>" ).arg( text, details ) );
496
case INFO_OPENING_WALLET_FAILED:
498
KMessageBox::information( parent, i18n( "<qt>The wallet \"%1\" could not be opened. KWallet support will be disabled for this session.</qt>" ).arg( text ) );