Smb4K – Samba (SMB) share advanced browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

409 lines
14 KiB

  1. /***************************************************************************
  2. smb4kerror - This is the class that manages the error messages.
  3. -------------------
  4. begin : Fr Sep 22 2006
  5. copyright : (C) 2006 by Alexander Reinholdt
  6. email : dustpuppy@mail.berlios.de
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. * This program is distributed in the hope that it will be useful, but *
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  17. * General Public License for more details. *
  18. * *
  19. * You should have received a copy of the GNU General Public License *
  20. * along with this program; if not, write to the *
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
  22. * MA 02110-1301 USA *
  23. ***************************************************************************/
  24. // KDE includes
  25. #include <tdemessagebox.h>
  26. #include <tdelocale.h>
  27. // application specific includes
  28. #include "smb4kerror.h"
  29. #include "smb4kdefs.h"
  30. void Smb4KError::error( int code, const TQString &text, const TQString &details )
  31. {
  32. switch ( code )
  33. {
  34. case ERROR_GETTING_BROWSELIST:
  35. {
  36. if ( details.stripWhiteSpace().isEmpty() )
  37. {
  38. KMessageBox::error( 0, i18n( "The browse list could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
  39. }
  40. else
  41. {
  42. KMessageBox::detailedError( 0, i18n( "The browse list could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
  43. }
  44. break;
  45. }
  46. case ERROR_GETTING_MEMBERS:
  47. {
  48. if ( details.stripWhiteSpace().isEmpty() )
  49. {
  50. KMessageBox::error( 0, i18n( "The list of servers could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
  51. }
  52. else
  53. {
  54. KMessageBox::detailedError( 0, i18n( "The list of servers could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
  55. }
  56. break;
  57. }
  58. case ERROR_GETTING_SHARES:
  59. {
  60. if ( details.stripWhiteSpace().isEmpty() )
  61. {
  62. KMessageBox::error( 0, i18n( "The list of shares could not be retrieved.\nDetailed information cannot be provided because there was no error message." ) );
  63. }
  64. else
  65. {
  66. KMessageBox::detailedError( 0, i18n( "The list of shares could not be retrieved.\nRead the error message under \"Details\" to find out more." ), details );
  67. }
  68. break;
  69. }
  70. case ERROR_GETTING_PREVIEW:
  71. {
  72. if ( details.stripWhiteSpace().isEmpty() )
  73. {
  74. KMessageBox::error( 0, i18n( "The preview could not be compiled.\nDetailed information cannot be provided because there was no error message." ) );
  75. }
  76. else
  77. {
  78. KMessageBox::detailedError( 0, i18n( "The preview could not be compiled.\nRead the error message under \"Details\" to find out more." ), details );
  79. }
  80. break;
  81. }
  82. case ERROR_OPENING_WALLET_FAILED:
  83. {
  84. KMessageBox::error( 0, i18n( "The wallet \"%1\" could not be opened. TDEWallet support will be disabled for this session." ).arg( text ) );
  85. break;
  86. }
  87. case ERROR_GETTING_PERMISSIONS:
  88. {
  89. if ( details.stripWhiteSpace().isEmpty() )
  90. {
  91. KMessageBox::error( 0, i18n( "Some file permissions could not be determined.\nDetailed information cannot be provided because there was no error message." ) );
  92. }
  93. else
  94. {
  95. KMessageBox::detailedError( 0, i18n( "Some file permissions could not be determined.\nRead the error message under \"Details\" to find out more." ), details );
  96. }
  97. break;
  98. }
  99. case ERROR_UNMOUNTING_NOT_ALLOWED:
  100. {
  101. KMessageBox::error( 0, i18n( "You are not allowed to unmount this share, because it is owned by another user." ) );
  102. break;
  103. }
  104. case ERROR_MOUNTING_SHARE:
  105. {
  106. if ( details.stripWhiteSpace().isEmpty() )
  107. {
  108. KMessageBox::error( 0, i18n( "The share \"%1\" could not be mounted.\nDetailed information cannot be provided because there was no error message." ).arg( text ) );
  109. }
  110. else
  111. {
  112. KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be mounted.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  113. }
  114. break;
  115. }
  116. case ERROR_UNMOUNTING_SHARE:
  117. {
  118. if ( details.stripWhiteSpace().isEmpty() )
  119. {
  120. KMessageBox::error( 0, i18n( "The share \"%1\" could not be unmounted.\nDetailed information cannot be provided because there was no error message." ).arg( text ) );
  121. }
  122. else
  123. {
  124. KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be unmounted.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  125. }
  126. break;
  127. }
  128. case ERROR_FILE_NOT_FOUND:
  129. {
  130. KMessageBox::error( 0, i18n( "The file \"%1\" could not be found." ).arg( text ) );
  131. break;
  132. }
  133. case ERROR_READING_FILE:
  134. {
  135. if ( details.stripWhiteSpace().isEmpty() )
  136. {
  137. KMessageBox::error( 0, i18n( "The file \"%1\" could not be read." ).arg( text ) );
  138. }
  139. else
  140. {
  141. KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be read.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  142. }
  143. break;
  144. }
  145. case ERROR_GETTING_HOSTNAME:
  146. {
  147. if ( details.stripWhiteSpace().isEmpty() )
  148. {
  149. 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." ) );
  150. }
  151. else
  152. {
  153. 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 );
  154. }
  155. break;
  156. }
  157. case ERROR_MISSING_PROGRAMS:
  158. {
  159. 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." ).arg( text ) );
  160. break;
  161. }
  162. case ERROR_LOCKED:
  163. {
  164. 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." ).arg( text.section( ":", 1, 1 ), text.section( ":", 0, 0 ) ) );
  165. break;
  166. }
  167. case ERROR_MKDIR_FAILED:
  168. {
  169. KMessageBox::error( 0, i18n( "The directory \"%1\" could not be created." ).arg( text ) );
  170. break;
  171. }
  172. case ERROR_WRITING_FILE:
  173. {
  174. KMessageBox::error( 0, i18n( "The file \"%1\" could not be written." ).arg( text ) );
  175. break;
  176. }
  177. case ERROR_MOUNTPOINT_EMPTY:
  178. {
  179. KMessageBox::error( 0, i18n( "The share could not be unmounted, because the mount point string was empty." ) );
  180. break;
  181. }
  182. case ERROR_FEATURE_NOT_ENABLED:
  183. {
  184. KMessageBox::error( 0, i18n( "This feature has not been enabled." ) );
  185. break;
  186. }
  187. case ERROR_BOOKMARK_PRINTER:
  188. {
  189. KMessageBox::error( 0, i18n( "Printers cannot be bookmarked." ) );
  190. break;
  191. }
  192. case ERROR_IP_CANNOT_BE_USED:
  193. {
  194. KMessageBox::sorry( 0, i18n( "IP addresses are not supported with this search method. Please choose \"Use nmblookup\" in the configuration dialog and try again." ) );
  195. break;
  196. }
  197. case ERROR_IMPORTING_SHARES:
  198. {
  199. if ( details.stripWhiteSpace().isEmpty() )
  200. {
  201. 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." ) );
  202. }
  203. else
  204. {
  205. 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 );
  206. }
  207. break;
  208. }
  209. case ERROR_COMMAND_NOT_FOUND:
  210. {
  211. KMessageBox::error( 0, i18n( "The command \"%1\" could not be found." ).arg( text ) );
  212. break;
  213. }
  214. case ERROR_PRINTING:
  215. {
  216. if ( details.stripWhiteSpace().isEmpty() )
  217. {
  218. KMessageBox::error( 0, i18n( "The file \"%1\" could not be printed.\nDetailed information cannot be provided because there was no error message." ).arg( text ) );
  219. }
  220. else
  221. {
  222. KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be printed.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  223. }
  224. break;
  225. }
  226. case ERROR_CREATING_TEMP_DIR:
  227. {
  228. if ( details.stripWhiteSpace().isEmpty() )
  229. {
  230. KMessageBox::error( 0, i18n( "The temporary directory \"%1\" could not be created.\nDetailed information cannot be provided because there was no error message." ).arg( text ) );
  231. }
  232. else
  233. {
  234. KMessageBox::detailedError( 0, i18n( "The temporary directory \"%1\" could not be created.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  235. }
  236. break;
  237. }
  238. case ERROR_CREATING_TEMP_FILE:
  239. {
  240. if ( details.stripWhiteSpace().isEmpty() )
  241. {
  242. KMessageBox::error( 0, i18n( "The temporary file \"%1\" could not be created.\nDetailed information cannot be provided because there was no error message." ).arg( text ) );
  243. }
  244. else
  245. {
  246. KMessageBox::detailedError( 0, i18n( "The temporary file \"%1\" could not be created.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  247. }
  248. break;
  249. }
  250. case ERROR_DIRECTORY_NOT_FOUND:
  251. {
  252. KMessageBox::error( 0, i18n( "The directory \"%1\" could not be found." ).arg( text ) );
  253. break;
  254. }
  255. case ERROR_FILE_IS_IRREGULAR:
  256. {
  257. 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." ).arg( text ) );
  258. break;
  259. }
  260. case ERROR_SYNCHRONIZING:
  261. {
  262. if ( details.stripWhiteSpace().isEmpty() )
  263. {
  264. KMessageBox::error( 0, i18n( "The synchronization could not the accomplished successfully.\nDetailed information cannot be provided because there was no error message." ) );
  265. }
  266. else
  267. {
  268. KMessageBox::detailedError( 0, i18n( "The synchronization could not the accomplished successfully.\nRead the error message under \"Details\" to find out more." ), details );
  269. }
  270. break;
  271. }
  272. case ERROR_OPENING_FILE:
  273. {
  274. if ( details.stripWhiteSpace().isEmpty() )
  275. {
  276. KMessageBox::error( 0, i18n( "The file \"%1\" could not be opened." ).arg( text ) );
  277. }
  278. else
  279. {
  280. KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be opened.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  281. }
  282. break;
  283. }
  284. case ERROR_CLOSING_FILE:
  285. {
  286. if ( details.stripWhiteSpace().isEmpty() )
  287. {
  288. KMessageBox::error( 0, i18n( "The file \"%1\" could not be closed." ).arg( text ) );
  289. }
  290. else
  291. {
  292. KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be closed.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
  293. }
  294. break;
  295. }
  296. case ERROR_NET_COMMAND:
  297. {
  298. KMessageBox::error( 0, i18n( "The list of arguments for the \"net\" command could not be assembled.\nAt the moment it reads: %1" ).arg( text ) );
  299. break;
  300. }
  301. case ERROR_GETTING_GIDS:
  302. {
  303. if ( details.stripWhiteSpace().isEmpty() )
  304. {
  305. KMessageBox::error( 0, i18n( "The list of supplementary group IDs could not be determined." ) );
  306. }
  307. else
  308. {
  309. 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 );
  310. }
  311. break;
  312. }
  313. case ERROR_UNKNOWN:
  314. default:
  315. {
  316. if ( details.stripWhiteSpace().isEmpty() )
  317. {
  318. KMessageBox::error( 0, i18n( "An unknown error occurred.\nDetailed information cannot be provided because there was no error message." ) );
  319. }
  320. else
  321. {
  322. KMessageBox::detailedError( 0, i18n( "An unknown error occurred.\nRead the error message under \"Details\" to find out more." ), details );
  323. }
  324. break;
  325. }
  326. }
  327. }
  328. int Smb4KError::warning( int code, const TQString &, const TQString & )
  329. {
  330. switch ( code )
  331. {
  332. default:
  333. {
  334. return 0;
  335. }
  336. }
  337. }
  338. void Smb4KError::information( int code, const TQString &text, const TQString &details )
  339. {
  340. switch ( code )
  341. {
  342. case INFO_MIMETYPE_NOT_SUPPORTED:
  343. {
  344. KMessageBox::information( 0, i18n( "The mimetype \"%1\" is not supported. Please convert the file to PostScript or PDF." ).arg( text ) );
  345. break;
  346. }
  347. case INFO_DISABLE_SUID_FEATURE:
  348. {
  349. KMessageBox::information( 0, i18n( "You previously chose to use \"%1\", but now it is missing on your system. Smb4K will disable this feature." ).arg( text ) );
  350. break;
  351. }
  352. case INFO_BOOKMARK_LABEL_IN_USE:
  353. {
  354. KMessageBox::information( 0, i18n( "The label \"%1\" is used more than once. It will automatically be renamed for bookmark \"%2\" to avoid confusion." ).arg( text, details ) );
  355. break;
  356. }
  357. default:
  358. {
  359. break;
  360. }
  361. }
  362. }
  363. // No moc file needs to be included