Added old KDE3 version of SMB4K

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smb4k@1097609 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
commit 854bf52eeb

@ -0,0 +1,8 @@
Developers:
Alexander Reinholdt <dustpuppy@users.berlios.de>
Massimo Callegari <mcallegari@users.berlios.de>
Franck Babin <babinfranck@yahoo.ca> (retired)
Translators:
The current list of translators can be found at
http://smb4k.berlios.de

10
BUGS

@ -0,0 +1,10 @@
You are strongly encouraged to commit a bug report to
http://developer.berlios.de/bugs/?group_id=769, if you find a problem.
Please do not forget to include:
(a) a detailed description of what you did to receive the issue you are
reporting
(b) the error message or backtrace.
(c) the version of Smb4K you are using
(d) the operating system and distribution (in case of Linux) you are using
(e) all additional information that might be helpful to reproduce and
fix the bug

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,283 @@
# Doxyfile 1.5.1-KDevelop
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = smb4k
PROJECT_NUMBER = CVS_HEAD
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = /home/alex/
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = /home/alex/Entwicklung/smb4k_09
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM \
*.PY \
*.C \
*.H \
*.tlh \
*.diff \
*.patch \
*.moc \
*.xpm \
*.dox
RECURSIVE = yes
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = yes
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = smb4k.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

344
FAQ

@ -0,0 +1,344 @@
Frequently Asked Questions (FAQ)
================================
(Version: 2005-12-20)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! This file is deprecated. Please refer to the "Frequently Asked Questions" !
! section of the handbook for the latest version of the FAQ. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Reporting bugs
--------------
Q: I think, I found a bug. Where can I report it?
A: There are two possible ways, how to do it. You can either click on the
menu item Help->Report Bug... and submit your report there, or you go to
the project's bug tracking site:
http://developer.berlios.de/bugs/?group_id=769.
NOTE:
- Before reporting a bug, try the latest version of Smb4K. Maybe the bug
you found has already been fixed.
- If you are reporting a bug, please include as much information as
possible. To reproduce your problem, it is mandatory that you tell us
what you did exactly. Also, it is necessary that you provide the version
of Smb4K and KDE that you are using and which operating system (Linux,
FreeBSD, etc.) and distribution (if applicable) is running on your
computer.
Compilation and Installation
----------------------------
Q: I have compiled Smb4K from source. After starting it, I can't see the
toolbar. What went wrong?
A: Most likely, you installed Smb4K to the wrong place. To correct this,
uninstall Smb4K first. Go to the source's root directory and run
$ su -c "make uninstall"
from the shell.
NOTE:
This will not work, if you ran
$ make distclean
in the meantime.
Now, reconfigure the source by passing the '--prefix=PREFIX' option to
the configure script:
$ ./configure --prefix=`kde-config --prefix`
Afterwards, compile and install it:
$ make && su -c "make install"
Smb4K will be installed to the right path and everything should work fine.
Q: I want to compile Smb4K from source and I want to be able to uninstall it
easily. Is that possible?
A: If you want to be able to uninstall Smb4K easily, you might want to use
checkinstall. It keeps track of all files installed by the "make install"
command or equivalent, creates a Slackware, RPM, or Debian package with
those files, and adds it to the installed packages database, allowing for
easy package removal or distribution.
Configuration, compilation and installation using checkinstall will work
like this (see also above):
$ ./configure --prefix=`kde-config --prefix` && make && su -c "checkinstall"
Q: The configure script fails and tells me, it can't find my Qt
installation.
A: There are two things you should check:
1. It may be that the Qt header files are not installed. If this is true,
install them and run the configure script again.
2. The QTDIR environment variable might not be set properly or at all.
Check for the following line in your ~/.bashrc file
export QTDIR=PREFIX
and add it, if it is not present. Replace PREFIX with the prefix of your
Qt installation. Run
$ source ~/.bashrc
from the shell. Now, you're set for a second configuration attempt.
If the header files are installed and the QTDIR variable is set, but you
still get the same error, you might want to try to pass the
'--with-qt-includes=/path/to/header/files' option to the configure script.
Q: The configure script fails and tells me, it can't find my KDE
installation.
A: There are two things you should check:
1. Probably the KDE header files are not installed. If so, install them and
run the configure script again.
2. The KDEDIR environment variable might not be set properly or at all.
Check for the following line in your ~/.bashrc file
export KDEDIR=PREFIX
and add it, if it is not present. Replace PREFIX with the prefix of your
KDE installation. Run
$ source ~/.bashrc
from the shell. Now, you're set for a new configuration attempt.
Browsing
--------
Q: When I scan the network, there are several workgroups appearing, that
are not accessible. What can I do to avoid this behavior?
A: This behavior might be caused by Samba's enhancements to cross-subnet browse
propagation (see smb.conf(5) manual page). You can switch off this feature in
the smb.conf by adding the following entry to the [global] section:
[global]
...
enhanced browsing = no
...
This option seems to have no effect, if you do not use a WINS server.
Q: When I start Smb4K, there is nothing in the network browser!
A: Please follow this list to fix the problem:
- If your network has a WINS server, add it to the [global] section of
your smb.conf file and restart Samba (if necessary) and Smb4K.
- Make sure the SMB ports 137 (TCP+UDP), 138 (UDP), 139 (TCP+UDP), and 445
(TCP+UDP) are not blocked by a firewall. If you are using SUSE's firewall,
see below.
- Try to use a different look-up method. Therefore, change the settings
under Settings->Configure Smb4K...->Network->Browse List.
If there still isn't anything visible in the browser widget, ask for help on
the Smb4K-general mailing list or file a bug report.
Q: I'm using SUSE Linux with its firewall enabled. As normal user, I cannot
browse the network neighborhood. The browser window is always empty.
A: The solution to this issue is covered by several pages on the net. You may
want to take a look at:
- Novell Cool Solutions:
http://www.novell.com/coolsolutions/feature/11952.html
- HOWTO at TweakHound:
http://www.tweakhound.com/linux/samba/page_8.htm
- SUSE Linux Forums:
http://forums.suselinuxsupport.de/
Q: If I open a Windows 98 server, there are no shares shown although I know
that there should be serveral. What's wrong?
A: As of version 0.6.0, Smb4K uses the 'net' command to retrieve the list of
shares from a host. With the default settings, the 'net' command will try
to guess the protocol that is needed to communicate with the server (RAP or
RPC). Unfortunately, this does not seems to work well with Windows 98 and
earlier. To make things work, go to Settings->Configure Smb4K...->Samba->
net->Protocol and check the RAP button.
NOTE:
This does not apply to versions prior to 0.6.0, because they use the RAP
protocol based 'smbclient' command to retrieve the browse list. Smb4K
0.7.0 and above will automatically rescan the target server with the RAP
protocol if the first attempt failed.
Mounting/Unmounting of shares
-----------------------------
Q: Mounting a share fails and I get the following error message:
smbmnt must be installed suid root for direct user mounts (500,500)
smbmnt failed: 1
What does that mean?
A: It means, that you do not have enough permissions to mount SMB shares.
There are two things you can do:
1. Set the SUID root bit for smbmnt. Therefore you have to find out,
where the binary is located. Try
$ ls -la `which smbmnt`
in the shell. If this is a symlink, follow it to find the binary.
Change into the directory, where smbmnt resides and run
$ chmod +s smbmnt
Now the mounting should work.
WARNING:
Do not set the SUID root bit for smbmount! If you do, mounting will
too fail with the following error message:
libsmb based programs must *NOT* be setuid root.
6002: Connection to dustpuppy failed
SMB connection failed
2. You can execute mount and umount SUID using the program super (since
Smb4K 0.4.0) or sudo (since Smb4K 0.5.0). To enable this feature, you
have to go to Settings->Configure Smb4K...->Super User and adjust the
settings.
Q: If I want to unmount a share, I get the following message:
smbumount must be installed suid root
What do I have to do?
A: You have similar options as above. Either you set the SUID root bit for
smbumount or you enable the feature "Use super user privileges to mount and
unmount shares" under Settings->Configure Smb4K...->Super User->Actions.
For details see above.
Q: I'm using the CIFS file system for mounting and I've set the UID/GID in
the configuration dialog, but Smb4K does not seem to care about that at
all!
A: This is a Samba feature. If the target server supports the CIFS Unix
extentions, the uid and gid option will be ignored. For more information
see the mount.cifs(8) manual page.
Q: When I try to mount a share from a Windows 2003 server, I get the following
error message
cli_negprot: SMB signing is mandatory and we have disabled it.
4377: protocol negotiation failed
SMB connection failed
and the mounting fails. What's wrong?
A: You are using the SMBFS file system that does not support signing. You
have to switch to the CIFS file system in order to be able to mount the
share. Go to Settings->Configure Smb4K...->Samba->File System and choose
CIFS instead of SMBFS.
NOTE:
Smb4K will use the mount.cifs binary to mount CIFS shares. That's why
you should also enable the "Use super user privileges to mount and unmount
shares" option under Settings->Configure Smb4K...->Super User->Actions.
Q: Smb4K fails unmounting a share. The error message is:
Could not unmount /mount/point: Device or resource busy
How can I make unmounting work?
A: First of all, check that you haven't opened the mount point or one of its
subdirectories in a shell or with a file manager. Also, make sure you
haven't opened any file belonging to the share. If neither is the case,
you might have encountered a problem, that is known but not related to
Smb4K. It seems, that under certain circumstances (that we could not
figure out exactly) kdeinit (KDE < 3.4) background processes access files
and/or directories of the share and keep them open. Unmounting is not
possible unless you send
$ kill -HUP <PID>
to each kdeinit instance that has access to the share or its files.
Alternatively, you can force the unmounting of the share. Highlight the
share and use the Shares->Force Unmounting menu item or press Ctrl+F.
Q: I'm using sudo and the CIFS file system. Everytime I want to mount a share
(from a Windows 2003 server), I get the following error:
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
What can I do to make mounting work?
A: It is very possible, that the 'env_reset' flag has been set in the
/etc/sudoers file (It's the default in Gentoo for example.), which
resets the environment to only contain a limited number of environment
variables. Especially, the PASSWD variable is removed which is needed by
Smb4K.
To make mounting work, there are three things you should try alternatively:
- Insert manually the following line after the line beginning with
"User_Alias SMB4KUSERS":
Defaults:SMB4KUSERS env_keep=PASSWD
This should be the preferred method on a multi-user system.
- Remove the Smb4K user entries from /etc/sudoers manually or using
Smb4K and rewrite them (Smb4K >= 0.6.4).
- Comment out the 'env_reset' variable (not recommended).
If you are still not able to mount a share, please file a bug report.
Miscellaneous
-------------
Q: I'm using Smb4K 0.4.x. After starting it, I cannot see the main window.
Is this a bug?
A: No. This is a special behavior of the 0.4.x series, which was changed in
later releases. Smb4K 0.4.x immediately docks to the system tray. You'll
find an icon there with which you can bring up the main window. Restoring
the visible main window after logging in will not work.
Q: I want to use super to mount and unmount the shares. When I try to enable
either "Use super user privileges to force the unmounting of (broken)
shares" or "Use super user privileges to mount and unmount shares", Smb4K
complains that it cannot find the super.tab file. What do I have to do?
A: Create the super.tab file in the appropriate etc directory. Therefore
change into it (most likely /etc (Linux) or /usr/local/etc (FreeBSD)) and
run
$ touch super.tab && chmod 0644 super.tab
as root. Smb4K will take care of the rest.
Q: After installing Smb4K, I wanted to take advantage of the Konqueror
plugin but I couldn't find it. What do I have to do?
A: Right-click on the frame of Konqueror's navigation widget and choose
Add New->Samba Browser from the menu. The Konqueror plugin will be
added.

@ -0,0 +1,167 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes a while. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Type `make install' to install the programs and any data files and
documentation.
4. You can remove the program binaries and object files from the
source code directory by typing `make clean'.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

@ -0,0 +1,21 @@
if compile_konqplugin
PLUGINDIR=plugin
endif
EXTRA_DIST = admin AUTHORS COPYING ChangeLog INSTALL README TODO smb4k.lsm BUGS FAQ
AUTOMAKE_OPTIONS = foreign 1.5
MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files
package-messages:
$(MAKE) -f admin/Makefile.common package-messages
$(MAKE) -C po merge
#include admin/deps.am
SUBDIRS = smb4k $(PLUGINDIR) utilities po doc
messages: rc.cpp
$(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
$(XGETTEXT) `find . -name \*.cpp` -o $(podir)/smb4k.pot

@ -0,0 +1,14 @@
all:
@echo "This Makefile is only for the CVS repository"
@echo "This will be deleted before making the distribution"
@echo ""
@if test ! -d admin; then \
echo "Please recheckout this module!" ;\
echo "for cvs: use checkout once and after that update again" ;\
echo "for cvsup: checkout kde-common from cvsup and" ;\
echo " link kde-common/admin to ./admin" ;\
exit 1 ;\
fi
$(MAKE) -f admin/Makefile.common cvs
.SILENT:

168
README

@ -0,0 +1,168 @@
Smb4K README (version 0.9.x)
============================
Smb4K is an SMB/CIFS share browser for KDE. It uses the Samba software suite to
access the SMB/CIFS shares of the local network neighborhood. Its purpose is to
provide a program that's easy to use and has as many features as possible.
Features:
---------
- Scanning for (active) workgroups, hosts, and shares
- Mounting and unmounting of SMB/CIFS shares, including unmounting all shares
at once
- Access to the files of a mounted SMB/CIFS share using Konqueror
- Auto-detection of external mounts/unmounts
- Mounting of recently used shares on start-up
- Miscellaneous infos about the SMB/CIFS shares
- Network search
- WINS server support
- Preview of SMB/CIFS shares
- Selectable look-up and search methods
- Default login
- Ability to execute mount and umount SUID root
- Special handling of homes shares
- Ability to bookmark favorite shares
- System tray icon
- Support of advanced Samba options
- Support of printer shares
- Konqueror plugin
- KWallet support
- Synchronization of a remote share with a local copy and vice versa
- Ability to define custom options for individual servers and shares
Translations:
-------------
For the list of currently supported translations please visit Smb4K's home page
at http://smb4k.berlios.de/information.html.
Supported operating systems:
----------------------------
Smb4K officially supports Linux (kernel >= 2.2.x) and since version 0.4.1 also
FreeBSD (>= 4.10-RELEASE). Smb4K might also run on other operating system (e.g.
Solaris).
Requirements:
-------------
This version of Smb4K depends on the development files of the following
libraries:
- KDE Libs & Base (>= 3.3.0): The powerful Open Source graphical desktop
environment for Unix workstations [http://www.kde.org]
- Qt (>= 3.3.0): A multiplatform C++ application development framework.
[http://www.trolltech.no]
- X.org or XFree86 - Freely redistributable implementations of the X Window
System [http://www.x.org or http://www.xfree86.org]
- An implementation of the C library
Make sure that you also have installed all header files of the libraries Qt
and KDE are depending on. Recent versions of automake and autoconf are also
needed.
For a proper operation, you implicitly need:
- Support of the /proc filesystem compiled into your kernel if you are using
Linux
- A sh-compatible shell (bash, dash, ash, etc.) with an existing link /bin/sh
or the sh shell itself.
- Samba (3.x) - Tools to access to a server's filespace and printers via
SMB [http://www.samba.org]
- grep - GNU grep [http://www.gnu.org/directory/grep.html]
- GNU awk (GAWK) or similar - A pattern scanning and processing language.
[http://www.gnu.org/directory/gawk.html]
- sed - The GNU stream editor [http://www.gnu.org/directory/sed.html]
- findutils (xargs) - The GNU Find Utilities are the basic directory searching
utilities of the GNU operating system
[http://www.gnu.org/directory/findutils.html]
- util-linux (mount, umount) - Miscellaneous system utilities
[ftp://ftp.kernel.org/pub/linux/utils/util-linux]
To enable full functionality, you may also want to install these packages:
- super or sudo - Programs to allow general users to do superuser things
[ftp://ftp.ucolick.org/pub/users/will/ or http://www.sudo.ws/sudo/]
- teTeX or similar (dvips) - A TeX distribution for Unix
[http://tug.org/teTeX/]
- GNU enscript - A tool to convert ASCII files to PostScript
[http://people.ssh.fi/mtr/genscript/]
- rsync - A file transfer program to keep (remote) files in sync
[http://rsync.samba.org/]
Compilation and Installation
----------------------------
(a) Full installation:
1. Change into the root directory of the source code:
$ cd smb4k-x.x.x
(Replace x.x.x with the version number)
2. Configure the source code with at least the following command
$ ./configure --prefix=`kde-config --prefix`
Several more options can be added. Run
$ ./configure --help
to find out which ones are available.
3. Compile the source code:
$ make
4. Install the application. For that, become root
$ su
and run
$ make install
in the root directory of the source code. If you want to be able to
remove Smb4K with your package manager, install the 'checkinstall'
package and run
$ checkinstall
instead.
(b) Installation without Konqueror plugin:
Those of you, who do not use KDE or who do not wish to install the Konqueror
plugin, should run this configure command
$ ./configure --prefix=`kde-config --prefix` --without-konqplugin
instead of the one mentioned above and else proceed as described.
Additional information about compiling and installing the software is available
in the INSTALL file.
Debugging the Source Code
-------------------------
If you experience crashes or similar and want to debug the source code yourself,
compile the source code with debugging symbols. The procedure is similar to the
one described in the "Compilation and Installation" section above except that
you need to modify the configure command slightly:
$ ./configure --prefix=`kde-config --prefix` --enable-debug=full
Now compile and install the program as stated above. If you do not want to
install but only debug the newly compiled program, you may execute Smb4K from
within the source code directory. Change into the 'smb4k' subdirectory and run:
$ ./smb4k --nofork
If you found the cause for a bug, please let us know. A backtrace or a patch
will be much appreciated.
Help and Support
----------------
If you encounter problems when using Smb4K and need help or support, please
read the 'Trouble Shooting' section of the handbook first. You can access the
handbook from the 'Help' menu by selecting the 'Smb4K Handbook' entry or by
pressing the F1 key. An online version handbook is also available at
http://smb4k.berlios.de/handbook/index.html. Most of the common problems that
arise when working with Smb4K are already covered there. If that's not the
case, we recommend that you contact the Smb4K-general mailing list at
https://lists.berlios.de/mailman/listinfo/smb4k-general to get help. Some of
the developers and many users are subscribed and can help.
Bugs
----
You are strongly encouraged to send a bug report to
http://developer.berlios.de/bugs/?group_id=769, if you find a problem. Please
do not forget to include information about the version of Smb4K and the
operating system you are using (Linux or FreeBSD). It might also help if you
mention the distribution you have installed (Linux).
If you experienced a crash, we would appreciate if you sent us the backtrace,
i.e. the output provided by KDE's crash dialog. Please see the section "Debug-
ging the Source Code" for a description how to make sure useful debugging output
is returned.
Copyright
---------
Smb4K is released under the terms of the GNU General Public License (GPL),
version 2. A copy of the license is available in the file COPYING.
Latest Version
--------------
The latest stable version of Smb4K is always available from the Smb4K home page
at http://smb4k.berlios.de.

65
TODO

@ -0,0 +1,65 @@
TODO list:
for 0.10.x:
- Make Smb4K a KDE4 program.
- Move to cmake.
- Use KConfigSkeletonItem::label() in the config dialog instead of the strings
present at the moment.
- Replace getenv( "USER" ) cuserid(). Use something like the following code
snippet:
char cu[L_cuserid];
user = QString::fromLocal8Bit( cuserid( cu ), -1 );
or
user = QString::fromLocal8Bit( cuserid( NULL ), -1 ); // returning static pointer
- Move smb4k/core subdirectory to the root directory of the source.
- Rename libsmb4kcore to libsmb4k?
- Make authentication entries accessible and editable through the configuration
dialog.
- Revise how Smb4K handles authentication data.
- Improve search? We want to be able to find *shares* (use smbtree). Maybe we
could also implement mounting.
- Move the GPL v3?
- If "default" options have been defined for Samba commands, they should not
appear in the command.
- Don't save information about foreign shares and about shares that only
use default values in ~/.kde/share/apps/smb4k/custom_options file.
- Rewrite Smb4KSambaOptionsHandler::netOptions().
- Allow more than one file manager.
- Implement scripting functionality (D-BUS/DCOP(?)).
- Add command line options (--no-tray-widget, --minimal, etc.)
- Move Smb4KWorkgroupItem, Smb4KHostItem, and Smb4KShareItem into own files.
Maybe rename them.
- Merge Smb4KShare and Smb4KShareItem. Add IP address and host.
- Save IP address with the information that's needed to remount a share.
- Use plain system functions to read /proc/mounts. This hopefully will lead
to lower CPU usage.
- Add the ability to define the file system for all shares of a server through
the "Custom Options" dialog.
- Open with different file managers: dolphin, thunar (XFCE), nautilus (GNOME),
...
Deferred:
- Introduce a smb4k:/ kio slave?
- Support SELinux.
- Make it configurable if the workgroup master browser should be queried
to retrieve the comment etc. for a host or not when using the IP scan
method.
- Smb4KMounter:
+ The functions of the mounter should only take Smb4KShare objects where
possible.
+ Smb4KMounter::mountShare() should take an Smb4KShareItem object (we have
to add Smb4KShareItem::m_ip, etc., for that).
- Remove SMBFS support as soon as it is removed from the kernel.
- Add possibility to download files and directories from the preview dialog.
- Add support for multiple port declarations in smb.conf (How?).
- Add eyecandy: If the mouse is over an icon, show it as active. Use KDE
settings (KControl).
- Use setGrid[XY]() in Smb4KShareWidget to dynamically adjust the item size
in list mode.
- Implement more 'net' commands. Especially the 'rpc shutdown' command seems
to be very nice.
- Allow multiple sync instances (remove synchronizer from Smb4KCore?).

File diff suppressed because it is too large Load Diff

881
aclocal.m4 vendored

@ -0,0 +1,881 @@
# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(AC_AUTOCONF_VERSION, [2.61],,
[m4_warning([this file was generated for autoconf 2.61.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.10'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.10.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.10.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 9
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], UPC, [depcc="$UPC" am_compiler_list=],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 13
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.60])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES(OBJC)],
[define([AC_PROG_OBJC],
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check for `mkdir -p'.
AC_DEFUN([AM_PROG_MKDIR_P],
[AC_PREREQ([2.60])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
dnl while keeping a definition of mkdir_p for backward compatibility.
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
dnl Makefile.ins that do not define MKDIR_P, so we do our own
dnl adjustment using top_builddir (which is defined more often than
dnl MKDIR_P).
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
case $mkdir_p in
[[\\/$]]* | ?:[[\\/]]*) ;;
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac
])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([acinclude.m4])

@ -0,0 +1,240 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the <Carbon/Carbon.h> header file. */
#undef HAVE_CARBON_CARBON_H
/* Define if you have the CoreAudio API */
#undef HAVE_COREAUDIO
/* Define to 1 if you have the <crt_externs.h> header file. */
#undef HAVE_CRT_EXTERNS_H
/* Defines if your system has the crypt function */
#undef HAVE_CRYPT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* define if the Konqueror plugin is compiled */
#undef HAVE_KONQPLUGIN
/* Define if you have libjpeg */
#undef HAVE_LIBJPEG
/* Define if you have libpng */
#undef HAVE_LIBPNG
/* Define if you have a working libpthread (will enable threaded code) */
#undef HAVE_LIBPTHREAD
/* Define if you have libz */
#undef HAVE_LIBZ
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if your system needs _NSGetEnviron to set up the environment */
#undef HAVE_NSGETENVIRON
/* Define if you have res_init */
#undef HAVE_RES_INIT
/* Define if you have the res_init prototype */
#undef HAVE_RES_INIT_PROTO
/* Define if you have a STL implementation by SGI */
#undef HAVE_SGI_STL
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have strlcat */
#undef HAVE_STRLCAT
/* Define if you have the strlcat prototype */
#undef HAVE_STRLCAT_PROTO
/* Define if you have strlcpy */
#undef HAVE_STRLCPY
/* Define if you have the strlcpy prototype */
#undef HAVE_STRLCPY_PROTO
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Suffix for lib directories */
#undef KDELIBSUFF
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `char *', as computed by sizeof. */
#undef SIZEOF_CHAR_P
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Defined if compiling without arts */
#undef WITHOUT_ARTS
/*
* jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system
* headers and I'm too lazy to write a configure test as long as only
* unixware is related
*/
#ifdef _UNIXWARE
#define HAVE_BOOLEAN
#endif
/*
* AIX defines FD_SET in terms of bzero, but fails to include <strings.h>
* that defines bzero.
*/
#if defined(_AIX)
#include <strings.h>
#endif
#if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H)
# include <sys/time.h>
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#endif
#if !defined(HAVE_RES_INIT_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
int res_init(void);
#ifdef __cplusplus
}
#endif
#endif
#if !defined(HAVE_STRLCAT_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
unsigned long strlcat(char*, const char*, unsigned long);
#ifdef __cplusplus
}
#endif
#endif
#if !defined(HAVE_STRLCPY_PROTO)
#ifdef __cplusplus
extern "C" {
#endif
unsigned long strlcpy(char*, const char*, unsigned long);
#ifdef __cplusplus
}
#endif
#endif
/*
* On HP-UX, the declaration of vsnprintf() is needed every time !
*/
#if !defined(HAVE_VSNPRINTF) || defined(hpux)
#if __STDC__
#include <stdarg.h>
#include <stdlib.h>
#else
#include <varargs.h>
#endif
#ifdef __cplusplus
extern "C"
#endif
int vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
#ifdef __cplusplus
extern "C"
#endif
int snprintf(char *str, size_t n, char const *fmt, ...);
#endif
#if defined(__SVR4) && !defined(__svr4__)
#define __svr4__ 1
#endif
/* type to use in place of socklen_t if not defined */
#undef kde_socklen_t
/* type to use in place of socklen_t if not defined (deprecated, use
kde_socklen_t) */
#undef ksize_t

@ -0,0 +1,2 @@
./admin/configure.in.min
configure.in.in

@ -0,0 +1,161 @@
dnl =======================================================
dnl FILE: ./admin/configure.in.min
dnl =======================================================
dnl This file is part of the KDE libraries/packages
dnl Copyright (C) 2001 Stephan Kulow (coolo@kde.org)
dnl This file is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Library General Public
dnl License as published by the Free Software Foundation; either
dnl version 2 of the License, or (at your option) any later version.
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Library General Public License for more details.
dnl You should have received a copy of the GNU Library General Public License
dnl along with this library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl Boston, MA 02110-1301, USA.
# Original Author was Kalle@kde.org
# I lifted it in some mater. (Stephan Kulow)
# I used much code from Janos Farkas
dnl Process this file with autoconf to produce a configure script.
AC_INIT(acinclude.m4) dnl a source file from your sub dir
dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)
dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH
dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM
dnl Perform program name transformation
AC_ARG_PROGRAM
dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(smb4k, 0.9.4) dnl searches for some needed programs
KDE_SET_PREFIX
dnl generate the config header
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
dnl Checks for programs.
AC_CHECK_COMPILERS
AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
KDE_PROG_LIBTOOL
dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS
KDE_USE_QT(3.3.0)
AC_PATH_KDE
dnl =======================================================
dnl FILE: configure.in.in
dnl =======================================================
#MIN_CONFIG(3.3.0)
#AM_KDE_MIN_VERSION(3.3.0)
dnl PACKAGE set before
dnl=========================================================================dnl
dnl Konqueror plugin dnl
dnl=========================================================================dnl
AC_ARG_WITH(
[konqplugin],
[AS_HELP_STRING([--with-konqplugin=ARG],
[build with Konqueror plugin (default ARG=yes)])],
[],
[with_konqplugin=yes])
if test x$with_konqplugin = xyes; then
KDE_CHECK_HEADER(
[konqsidebarplugin.h],
[AC_DEFINE(HAVE_KONQPLUGIN,1,
[define if the Konqueror plugin is compiled])],
[AC_MSG_ERROR([
***
*** Cannot build Konqueror plugin. Install the development files for KDE base
*** or pass the '--with-konqplugin=no' option to the configure script.
***])],
[]
)
else
DO_NOT_COMPILE="$DO_NOT_COMPILE plugin"
fi
AM_CONDITIONAL([compile_konqplugin], [test x$with_konqplugin = xyes])
KDE_CREATE_SUBDIRSLIST
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ doc/Makefile ])
AC_CONFIG_FILES([ doc/en/Makefile ])
AC_CONFIG_FILES([ plugin/Makefile ])
AC_CONFIG_FILES([ po/Makefile ])
AC_CONFIG_FILES([ smb4k/Makefile ])
AC_CONFIG_FILES([ smb4k/browser/Makefile ])
AC_CONFIG_FILES([ smb4k/configdlg/Makefile ])
AC_CONFIG_FILES([ smb4k/core/Makefile ])
AC_CONFIG_FILES([ smb4k/dialogs/Makefile ])
AC_CONFIG_FILES([ smb4k/icons/Makefile ])
AC_CONFIG_FILES([ smb4k/iconview/Makefile ])
AC_CONFIG_FILES([ smb4k/listview/Makefile ])
AC_CONFIG_FILES([ smb4k/searchdlg/Makefile ])
AC_CONFIG_FILES([ utilities/Makefile ])
AC_OUTPUT
# Check if KDE_SET_PREFIX was called, and --prefix was passed to configure
if test -n "$kde_libs_prefix" -a -n "$given_prefix"; then
# And if so, warn when they don't match
if test "$kde_libs_prefix" != "$given_prefix"; then
# And if kde doesn't know about the prefix yet
echo ":"`kde-config --path exe`":" | grep ":$given_prefix/bin/:" 2>&1 >/dev/null
if test $? -ne 0; then
echo ""
echo "Warning: you chose to install this package in $given_prefix,"
echo "but KDE was found in $kde_libs_prefix."
echo "For this to work, you will need to tell KDE about the new prefix, by ensuring"
echo "that KDEDIRS contains it, e.g. export KDEDIRS=$given_prefix:$kde_libs_prefix"
echo "Then restart KDE."
echo ""
fi
fi
fi
if test x$GXX = "xyes" -a x$kde_have_gcc_visibility = "xyes" -a x$kde_cv_val_qt_gcc_visibility_patched = "xno"; then
echo ""
echo "Your GCC supports symbol visibility, but the patch for Qt supporting visibility"
echo "was not included. Therefore, GCC symbol visibility support remains disabled."
echo ""
echo "For better performance, consider including the Qt visibility supporting patch"
echo "located at:"
echo ""
echo "http://bugs.kde.org/show_bug.cgi?id=109386"
echo ""
echo "and recompile all of Qt and KDE. Note, this is entirely optional and"
echo "everything will continue to work just fine without it."
echo ""
fi
if test "$all_tests" = "bad"; then
if test ! "$cache_file" = "/dev/null"; then
echo ""
echo "Please remove the file $cache_file after changing your setup"
echo "so that configure will find the changes next time."
echo ""
fi
else
echo ""
echo "Good - your configure finished. Start make now"
echo ""
fi

@ -0,0 +1,34 @@
#MIN_CONFIG(3.3.0)
#AM_KDE_MIN_VERSION(3.3.0)
AM_INIT_AUTOMAKE(smb4k,0.9.4)
dnl=========================================================================dnl
dnl Konqueror plugin dnl
dnl=========================================================================dnl
AC_ARG_WITH(
[konqplugin],
[AS_HELP_STRING([--with-konqplugin=ARG],
[build with Konqueror plugin (default ARG=yes)])],
[],
[with_konqplugin=yes])
if test x$with_konqplugin = xyes; then
KDE_CHECK_HEADER(
[konqsidebarplugin.h],
[AC_DEFINE(HAVE_KONQPLUGIN,1,
[define if the Konqueror plugin is compiled])],
[AC_MSG_ERROR([
***
*** Cannot build Konqueror plugin. Install the development files for KDE base
*** or pass the '--with-konqplugin=no' option to the configure script.
***])],
[]
)
else
DO_NOT_COMPILE="$DO_NOT_COMPILE plugin"
fi
AM_CONDITIONAL([compile_konqplugin], [test x$with_konqplugin = xyes])

@ -0,0 +1,2 @@
SUBDIRS = en
KDE_DOCS = AUTO

@ -0,0 +1,2 @@
KDE_LANG = en
KDE_DOCS = smb4k

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,13 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = konqsidebar_smb4k.la
konqsidebar_smb4k_la_SOURCES = smb4k_konqplugin.cpp
konqsidebar_smb4k_la_LDFLAGS = -module $(all_libraries) \
-L$(top_builddir)/smb4k/core -L$(topbuild_dir)/smb4k/widgets -lkonqsidebarplugin
konqsidebar_smb4k_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(KDE_PLUGIN) $(LIB_KFILE) $(LIB_KPARTS) $(LIB_QT) $(LIB_KDECORE) \
$(LIB_KDEUI)
globaladddir = $(kde_datadir)/konqsidebartng/add
globaladd_DATA = smb4k_add.desktop
noinst_HEADERS = smb4k_konqplugin.h

@ -0,0 +1,74 @@
# KDE Config File
[Desktop Entry]
Name=Samba Browser
Icon=smb4k
Type=Application
GenericName=The SMB/CIFS Share Browser
GenericName[bg]=Самба ресурсен четец
GenericName[ca]=El navegador de compartits SMB/CIFS
GenericName[cs]=Prohližeč SMB/CIFS sdílení
GenericName[de]=Der Browser für SMB/CIFS-Freigaben
GenericName[es]=El explorador de recursos compartidos SMB/CIFS
GenericName[fr]=L'explorateur de partages SMB / CIFS
GenericName[hu]=Az SMB/CIFS böngésző
GenericName[it]=Browser di condivisioni SMB/CIFS
GenericName[ja]=SMB/CIFS 共有(シェア)・ブラウザー
GenericName[nl]=De SMB/CIFS Share Browser
GenericName[no]=SMB/CIFS ressurs utforsker
GenericName[no_NY]=SMB/CIFS ressurs surfar
GenericName[pl]=Przeglądarka Zasobów SMB/CIFS
GenericName[pt_BR]=O navegador de compartilhamentos SMB/CIFS
GenericName[ru]=The SMB/CIFS Share Browser
GenericName[sk]=Prehliadač SMB/CIFS zdieľaní
GenericName[sv]=SMB Katalog programmed
GenericName[tr]=SMB/CIFS Paylaşım Tarayıcısı
GenericName[uk]=Навігатор спільних ресурсів SMB/CIFS
GenericName[zh_CN]=SMB 共享浏览器"
#
# The following lines seem to be necessary for SuSE.
#
Name[bg]=Samba Browser
Name[ca]=Samba Browser
Name[cs]=Samba Browser
Name[de]=Samba Browser
Name[es]=Samba Browser
Name[fr]=Samba Browser
Name[hu]=Samba Browser
Name[it]=Samba Browser
Name[ja]=Samba Browser
Name[nl]=Samba Browser
Name[no]=Samba Browser
Name[no_NY]=Samba Browser
Name[pl]=Samba Browser
Name[pt_BR]=Samba Browser
Name[ru]=Samba Browser
Name[sk]=Samba Browser
Name[sv]=Samba Browser
Name[tr]=Samba Tarayıcısı
Name[uk]=Samba Browser
Name[zh_CN]=Samba Browser
Comment=The SMB/CIFS Share Browser
Comment[bg]=Самба ресурсен четец
Comment[ca]=El navegador de compartits SMB/CIFS
Comment[cs]=Prohližeč SMB/CIFS sdílení
Comment[de]=Der Browser für SMB/CIFS-Freigaben
Comment[es]=El explorador de recursos compartidos SMB/CIFS
Comment[fr]=L'explorateur de partages SMB / CIFS
Comment[hu]=Az SMB/CIFS böngésző
Comment[it]=Browser di condivisioni SMB/CIFS
Comment[ja]=SMB/CIFS 共有(シェア)・ブラウザー
Comment[nl]=De SMB/CIFS Share Browser
Comment[no]=SMB/CIFS ressurs utforsker
Comment[no_NY]=SMB/CIFS ressurs surfar
Comment[pl]=Przeglądarka Zasobów SMB/CIFS
Comment[pt_BR]=O navegador de compartilhamentos SMB/CIFS
Comment[ru]=The SMB/CIFS Share Browser
Comment[sk]=Prehliadač SMB/CIFS zdieľaní
Comment[sv]=SMB Katalog programmed
Comment[tr]=SMB/CIFS Paylaşım Tarayıcısı
Comment[uk]=Навігатор спільних ресурсів SMB/CIFS
Comment[zh_CN]=SMB 共享浏览器"
X-Open=false
X-KDE-KonqSidebarAddModule=konqsidebar_smb4k
X-KDE-KonqSidebarUniversal=true

@ -0,0 +1,236 @@
/***************************************************************************
* Copyright (C) 2004 by Massimo Callegari *
* massimocallegari@yahoo.it *
* *
* 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. *
***************************************************************************/
// Qt includes
#include <qapplication.h>
#include <qlabel.h>
#include <qtooltip.h>
#include <qstring.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qheader.h>
#include <qvaluelist.h>
#include <qpixmap.h>
#include <qtoolbutton.h>
#include <qtoolbar.h>
#include <qdir.h>
#include <qpushbutton.h>
// KDE includes
#include <klibloader.h>
#include <kinstance.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kdialogbase.h>
#include <kcombobox.h>
#include <ktoolbarbutton.h>
#include <kaction.h>
#include <kactionclasses.h>
#include <kconfigdialog.h>
// plugin specific includes
// #include "smb4k_konqplugin.moc"
#include "smb4k_konqplugin.h"
#include "../smb4k/core/smb4kcore.h"
#include "../smb4k/core/smb4kdefs.h"
smb4kWidget::smb4kWidget( QWidget * parent, const char * name, WFlags f )
: QVBox(parent, name, f)
{
// Nothing exciting to do !
}
KonqSidebar_Smb4K::KonqSidebar_Smb4K(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name):
KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name)
{
widget = new smb4kWidget( widgetParent );
KToolBar *topBar = new KToolBar( widget, "Topbar" );
topBar->setIconSize(16);
topBar->insertButton( "reload", 0, SIGNAL( clicked() ), this, SLOT( slotRescan() ) , TRUE, i18n( "Scan Network" ) );
topBar->insertButton( "find", 1, SIGNAL( clicked() ), this, SLOT( slotSearch() ) , TRUE, i18n( "Search" ) );
topBar->insertButton( "configure", 2, SIGNAL( clicked() ), this, SLOT( slotSmb4KOptionsDlg() ) , TRUE, i18n( "Configure" ) );
//
// Browser widget:
//
KLibFactory *browser_factory = KLibLoader::self()->factory( "libsmb4knetworkbrowser" );
if ( browser_factory )
{
m_browser_part = static_cast<KParts::Part *>( browser_factory->create( widget, "BrowserPart", "KParts::Part", QStringList( "konqplugin=\"true\"" ) ) );
// Do nothing here. The network scan (and the mounting of recently used
// shares) will be done by Smb4KCore::init() below.
}
else
{
KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
return;
}
connect( Smb4KCore::mounter(), SIGNAL( mountedShare( const QString &) ), this, SLOT( slotMountedShare( const QString & ) ) );
connect( Smb4KCore::mounter(), SIGNAL( aboutToUnmount( const QString& ) ), this, SLOT( slotPrepareUnmount( const QString& ) ) );
// Scan the network and remount recently used shares:
Smb4KCore::self()->init();
}
KonqSidebar_Smb4K::~KonqSidebar_Smb4K()
{
}
extern "C"
{
void* create_konqsidebar_smb4k(KInstance *instance,QObject *par,QWidget *widp,QString &desktopname,const char *name)
{
KGlobal::locale()->insertCatalogue("smb4k");
return new KonqSidebar_Smb4K(instance,par,widp,desktopname,name);
}
};
extern "C"
{
bool add_konqsidebar_smb4k(QString* fn, QString* /*param*/, QMap<QString,QString> *map)
{
map->insert("Type","Link");
map->insert("Icon","smb4k");
map->insert("Name",i18n("Samba Browser"));
map->insert("Open","false");
map->insert("X-KDE-KonqSidebarModule","konqsidebar_smb4k");
fn->setLatin1("smb4k%1.desktop");
return true;
}
}
void KonqSidebar_Smb4K::handleURL(const KURL &url)
{
currentKonquerorURL = url.path();
//kdDebug() << "KonqSidebar_Smb4K::handleURL - "<< currentKonquerorURL << endl;
}
void KonqSidebar_Smb4K::slotRescan()
{
// Send a custom rescan event to the browser part.
QApplication::postEvent( m_browser_part, new QCustomEvent( EVENT_SCAN_NETWORK ) );
}
void KonqSidebar_Smb4K::slotSearch()
{
// Load the factory of the config dialog:
KLibFactory *search_factory = KLibLoader::self()->factory( "libsmb4ksearchdialog" );
if ( search_factory )
{
KDialogBase *searchDialog = new KDialogBase( KDialogBase::Plain, i18n( "Search Dialog" ), KDialogBase::Close,
KDialogBase::NoDefault, widget, "sd", true, true );
QFrame *frame = searchDialog->plainPage();
m_search_part = static_cast<KParts::Part *>( search_factory->create( frame, "SearchDialogPart", "KParts::Part" ) );
if ( m_search_part )
{
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 10 );
layout->setMargin( 0 );
layout->addWidget ( m_search_part->widget(), 0, 0, 0 );
searchDialog->resize(400,300);
// We do not want the dialog to be closed if the user presses return.
// Instead we want that a search is started:
searchDialog->actionButton( KDialogBase::Close )->setAutoDefault( false );
//connect( m_search_dialog, SIGNAL( searchResult( Smb4KHostItem * ) ), this, SLOT( slotInsertItem( Smb4KHostItem * ) ) );
searchDialog->show();
}
else
{
delete searchDialog;
}
}
else
{
KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
return;
}
}
void KonqSidebar_Smb4K::slotSmb4KOptionsDlg()
{
// Load the factory of the config dialog:
KLibFactory *config_factory = KLibLoader::self()->factory( "libsmb4kconfigdialog" );
if ( config_factory )
{
KConfigDialog *dlg = static_cast<KConfigDialog *>( config_factory->create( widget, "ConfigDialog", "KConfigDialog" ) );
if ( dlg )
{
connect( dlg, SIGNAL( settingsChanged() ), this, SLOT( slotSettingsChanged() ) );
dlg->show();
}
}
else
{
KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
return;
}
}
void KonqSidebar_Smb4K::slotSettingsChanged()
{
QApplication::postEvent( m_browser_part, new QCustomEvent( EVENT_LOAD_SETTINGS ) );
}
void KonqSidebar_Smb4K::slotMountedShare( const QString &mountedShare )
{
emit openURLRequest( KURL(mountedShare) );
}
void KonqSidebar_Smb4K::slotPrepareUnmount( const QString &mountpoint )
{
if ( QString::compare( currentKonquerorURL, mountpoint ) == 0 )
{
emit openURLRequest( KURL( QDir::home().canonicalPath() ) );
}
else
{
// Nothing to do
}
}
#include "smb4k_konqplugin.moc"

@ -0,0 +1,136 @@
/***************************************************************************
* Copyright (C) 2004 by Massimo Callegari *
* massimo.callegari@telsey.it *
* *
* 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. *
***************************************************************************/
#ifndef SAMBROWSER_H
#define SAMBROWSER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <konqsidebarplugin.h>
#include <qstring.h>
#include <qwidget.h>
#include <qvbox.h>
#include <qwidgetstack.h>
#include <kpopupmenu.h>
#include <ktoolbar.h>
#include <khtml_part.h>
// KDE includes
#include <kaction.h>
#include <kparts/dockmainwindow.h>
#include <kparts/part.h>
#include <kparts/factory.h>
class smb4kWidget : public QVBox
{
Q_OBJECT
public:
smb4kWidget( QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
private:
};
class KonqSidebar_Smb4K : public KonqSidebarPlugin
{
Q_OBJECT
public:
/**
* Construct a @ref KonqSidebarPlugin.
*
* @param inst The sidebar's kinstance class.
* @param parent The sidebar internal button info class responsible for this plugin.
* @param widgetParent The container which will contain the plugins widget.
* @param desktopName The filename of the configuration file.
* @param name A Qt object name for your plugin.
**/
KonqSidebar_Smb4K(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name=0);
/** destructor */
~KonqSidebar_Smb4K();
KHTMLPart* m_part;
virtual QWidget *getWidget(){ return (QWidget*)widget;}
virtual void *provides(const QString &) {return 0;}
void emitStatusBarText (const QString &) {;}
private:
/**
* The browser part
*/
KParts::Part *m_browser_part;
/**
* The search dialog part
*/
KParts::Part *m_search_part;
protected:
/**
* The main plugin widget. Contains a klistview and a ktoolbox objects
*/
smb4kWidget *widget;
QString currentKonquerorURL;
virtual void handleURL(const KURL &url);
protected slots:
/**
* This slot initializes a rescan of the network neighborhood.
*/
void slotRescan();
/**
* This slot is connected to the clicked() signal of the topBar search button
* It brings up the "Search" dialog.
*/
void slotSearch();
/**
* Opens the configuration dialog.
*/
void slotSmb4KOptionsDlg();
/**
* This slot is invoked when the config dialog is closed and the settings have
* been changed. Emits the reloadSettings() signal and adjusts the system tray
* widget to the new settings afterwards.
*/
void slotSettingsChanged();
/**
* Called from mounter when a share is mounted
*/
void slotMountedShare( const QString & );
/**
* Called from the mounter just before a share is unmounted. This slot
* changes the URL to the user's home so that we can unmount the share
* without problems.
*
* @param mountpoint The mount point of the share that's going to
* be unmounted.
*/
void slotPrepareUnmount( const QString &mounpoint );
signals:
// see <konqsidebarplugin.h>
void openURLRequest(const KURL &url,
const KParts::URLArgs &args = KParts::URLArgs());
};
#endif

@ -0,0 +1,4 @@
POFILES = AUTO
EXTRA_DIST=smb4k.pot

4040
po/de.po

File diff suppressed because it is too large Load Diff

3638
po/es.po

File diff suppressed because it is too large Load Diff

3624
po/it.po

File diff suppressed because it is too large Load Diff

3850
po/ja.po

File diff suppressed because it is too large Load Diff

4140
po/sv.po

File diff suppressed because it is too large Load Diff

3722
po/uk.po

File diff suppressed because it is too large Load Diff

@ -0,0 +1,274 @@
<!DOCTYPE kdevelop>
<kdevelop>
<general>
<author>Alexander Reinholdt</author>
<email>dustpuppy@users.berlios.de</email>
<projectmanagement>KDevKDEAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
<keyword>KDE</keyword>
<keyword>Qt</keyword>
</keywords>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<version>CVS_HEAD</version>
<description/>
<ignoreparts/>
<secondaryLanguages/>
<versioncontrol>kdevcvsservice</versioncontrol>
<projectname>smb4k</projectname>
<defaultencoding/>
</general>
<kdevautoproject>
<general>
<mainprogram>smb4k</mainprogram>
<useconfiguration>default</useconfiguration>
<activetarget>smb4k/widgets/print/libprint.a</activetarget>
</general>
<configure>
<configargs/>
</configure>
<make>
<abortonerror>false</abortonerror>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<envvars>
<envvar value="1" name="WANT_AUTOCONF_2_5" />
<envvar value="1" name="WANT_AUTOMAKE_1_8" />
</envvars>
<prio>0</prio>
</make>
<compiler>
<cflags/>
<cxxflags>\s-O0 -g3 -Wall</cxxflags>
</compiler>
<run>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<mainprogram>smb4k/smb4k</mainprogram>
<programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
<runarguments>
<smb4k_kill/>
<smb4k_umount/>
<smb4k_mount/>
<smb4k/>
</runarguments>
<debugarguments>
<smb4k/>
</debugarguments>
<cwd>
<smb4k>/home/alex/Entwicklung/smb4k_head/./</smb4k>
</cwd>
</run>
<configurations>
<default>
<configargs>--enable-debug=full</configargs>
<builddir/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevpgf77options</f77compiler>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
<envvars/>
</default>
</configurations>
</kdevautoproject>
<kdevfileview>
<groups>
<group pattern="*.h;*.hh;*.hxx;*.hpp;*.H" name="Header" />
<group pattern="*.cpp;*.c;*.cc;*.C;*.cxx;*.ec;*.ecpp;*.lxx;*.l++;*.ll;*.l" name="Quellen" />
<group pattern="*.kdevdlg;*.ui;*.rc;*.dlg" name="Benutzerschnittstelle" />
<group pattern="*.po" name="Übersetzungen" />
<group pattern="AUTHORS;COPYING;ChangeLog;INSTALL;README;TODO;NEWS" name="GNU" />
<group pattern="*" name="Andere" />
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidenonlocation>false</hidenonlocation>
</groups>
<tree>
<hidepatterns></hidepatterns>
<hidenonprojectfiles>false</hidenonprojectfiles>
<showvcsfields>false</showvcsfields>
</tree>
</kdevfileview>
<kdevdoctreeview>
<ignoretocs>
<toc>gtk</toc>
<toc>gnustep</toc>
<toc>python</toc>
<toc>php</toc>
<toc>perl</toc>
</ignoretocs>
<projectdoc>
<userdocDir>api-docs/html/</userdocDir>
<apidocDir>api-docs/html/</apidocDir>
</projectdoc>
<ignoreqt_xml/>
<ignoredoxygen/>
<ignorekdocs/>
<ignoredevhelp/>
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
<raiseGDBOnStart>false</raiseGDBOnStart>
</general>
<display>
<staticmembers>false</staticmembers>
<demanglenames>true</demanglenames>
<outputradix>10</outputradix>
</display>
</kdevdebugger>
<kdevcvs>
<cvsoptions>-f</cvsoptions>
<commitoptions/>
<addoptions/>
<logoptions/>
<updateoptions>-dP</updateoptions>
<removeoptions>-f</removeoptions>
<revertoptions>-C -d -P</revertoptions>
<diffoptions>-u3 -p</diffoptions>
<rshoptions/>
</kdevcvs>
<kdevcppsupport>
<references/>
<codecompletion>
<includeGlobalFunctions>true</includeGlobalFunctions>
<includeTypes>true</includeTypes>
<includeEnums>true</includeEnums>
<includeTypedefs>false</includeTypedefs>
<automaticCodeCompletion>true</automaticCodeCompletion>
<automaticArgumentsHint>true</automaticArgumentsHint>
<automaticHeaderCompletion>true</automaticHeaderCompletion>
<codeCompletionDelay>250</codeCompletionDelay>
<argumentsHintDelay>400</argumentsHintDelay>
<headerCompletionDelay>250</headerCompletionDelay>
<showOnlyAccessibleItems>false</showOnlyAccessibleItems>
<completionBoxItemOrder>0</completionBoxItemOrder>
<howEvaluationContextMenu>true</howEvaluationContextMenu>
<showCommentWithArgumentHint>true</showCommentWithArgumentHint>
<statusBarTypeEvaluation>false</statusBarTypeEvaluation>
<namespaceAliases>std=_GLIBCXX_STD;__gnu_cxx=std</namespaceAliases>
<processPrimaryTypes>true</processPrimaryTypes>
<processFunctionArguments>false</processFunctionArguments>
<preProcessAllHeaders>false</preProcessAllHeaders>
<parseMissingHeaders>false</parseMissingHeaders>
<resolveIncludePaths>true</resolveIncludePaths>
<alwaysParseInBackground>true</alwaysParseInBackground>
<usePermanentCaching>true</usePermanentCaching>
<alwaysIncludeNamespaces>false</alwaysIncludeNamespaces>
<includePaths>.;</includePaths>
<parseMissingHeadersExperimental>false</parseMissingHeadersExperimental>
<resolveIncludePathsUsingMakeExperimental>false</resolveIncludePathsUsingMakeExperimental>
</codecompletion>
<creategettersetter>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
<inlineGet>true</inlineGet>
<inlineSet>true</inlineSet>
</creategettersetter>
<qt>
<used>false</used>
<version>3</version>
<root>/usr/share/qt3</root>
<includestyle>3</includestyle>
<designerintegration>EmbeddedKDevDesigner</designerintegration>
<qmake>/usr/bin/qmake-qt3</qmake>
<designer>/usr/bin/designer</designer>
<designerpluginpaths/>
</qt>
<splitheadersource>
<enabled>false</enabled>
<synchronize>true</synchronize>
<orientation>Vertical</orientation>
</splitheadersource>
</kdevcppsupport>
<kdevfilecreate>
<filetypes>
<type icon="source_h" ext="h" create="template" name="C/C++ header" >
<descr>A new empty header file for C or C++.</descr>
</type>
<type icon="source_cpp" ext="cpp" create="template" name="C++ source" >
<descr>A new empty C++ file.</descr>
</type>
</filetypes>
<useglobaltypes/>
</kdevfilecreate>
<cppsupportpart>
<filetemplates>
<interfacesuffix>.h</interfacesuffix>
<implementationsuffix>.cpp</implementationsuffix>
</filetemplates>
</cppsupportpart>
<dist>
<custom>true</custom>
<bzip>false</bzip>
<archname/>
<appname>smb4k</appname>
<version>0.4.0cvs</version>
<release/>
<vendor/>
<licence/>
<summary/>
<group/>
<packager/>
<description/>
<changelog/>
<devpackage>false</devpackage>
<docspackage>false</docspackage>
<appicon>false</appicon>
<arch>0</arch>
<genHTML>false</genHTML>
<useRPM>false</useRPM>
<ftpkde>false</ftpkde>
<appskde>false</appskde>
<url/>
</dist>
<kdevcvsservice>
<recursivewhenupdate>true</recursivewhenupdate>
<prunedirswhenupdate>true</prunedirswhenupdate>
<createdirswhenupdate>true</createdirswhenupdate>
<recursivewhencommitremove>true</recursivewhencommitremove>
<revertoptions>-C</revertoptions>
</kdevcvsservice>
<kdevdocumentation>
<projectdoc>
<docsystem/>
<docurl/>
<usermanualurl>/home/alex/Entwicklung/smb4k_head/smb4k-api</usermanualurl>
</projectdoc>
</kdevdocumentation>
<ctagspart>
<customArguments/>
<customTagfilePath/>
</ctagspart>
<kdevvisualadvance>
<emulator>VisualBoyAdvance</emulator>
<binary/>
<addOptions/>
<terminal>false</terminal>
<fullscreen>false</fullscreen>
<graphicFilter>-f0</graphicFilter>
<scaling>-1</scaling>
</kdevvisualadvance>
</kdevelop>

Binary file not shown.

@ -0,0 +1,46 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="7" >
<Doc0 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/ChangeLog" >
<View0 Encoding="" line="0" Type="Source" />
</Doc0>
<Doc1 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/core/smb4kfileio.cpp" >
<View0 Encoding="" line="0" Type="Source" />
</Doc1>
<Doc2 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/configdlg/smb4kconfigdialog.cpp" >
<View0 Encoding="" line="0" Type="Source" />
</Doc2>
<Doc3 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/configdlg/smb4ksuperuseroptions.cpp" >
<View0 Encoding="" line="0" Type="Source" />
</Doc3>
<Doc4 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/core/smb4kscanner.cpp" >
<View0 Encoding="" line="399" Type="Source" />
</Doc4>
<Doc5 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/core/smb4kauthinfo.h" >
<View0 Encoding="" line="64" Type="Source" />
</Doc5>
<Doc6 NumberOfViews="1" URL="file:///home/alex/Entwicklung/smb4k_09/smb4k/core/smb4kglobal.h" >
<View0 Encoding="" line="82" Type="Source" />
</Doc6>
</DocsAndViews>
<pluginList>
<kdevdebugger>
<breakpointList/>
<showInternalCommands value="0" />
</kdevdebugger>
<kdevastyle>
<Extensions ext="*.cpp *.h,*.c *.h,*.cxx *.hxx,*.c++ *.h++,*.cc *.hh,*.C *.H,*.diff,*.inl,*.java,*.moc,*.patch,*.tlh,*.xpm" />
<AStyle IndentPreprocessors="0" FillCount="4" PadParenthesesOut="1" IndentNamespaces="1" IndentLabels="1" Fill="Tabs" MaxStatement="40" Brackets="Break" MinConditional="-1" IndentBrackets="0" PadParenthesesUn="1" BlockBreak="0" KeepStatements="1" KeepBlocks="1" BlockIfElse="0" IndentSwitches="1" PadOperators="0" FStyle="UserDefined" IndentCases="0" FillEmptyLines="0" BracketsCloseHeaders="0" BlockBreakAll="0" PadParenthesesIn="1" IndentClasses="1" IndentBlocks="0" FillForce="0" />
</kdevastyle>
<kdevbookmarks>
<bookmarks/>
</kdevbookmarks>
<kdevvalgrind>
<executable path="" params="" />
<valgrind path="" params="" />
<calltree path="" params="" />
<kcachegrind path="" />
</kdevvalgrind>
</pluginList>
</KDevPrjSession>

@ -0,0 +1,14 @@
Begin3
Title: Smb4K
Version: 0.1.1
Entered-date:
Description:
Keywords:
Author: Alexander Reinholdt <dustpuppy@mail.berlios.de>
Maintained-by: Alexander Reinholdt <dustpuppy@mail.berlios.de>
Primary-site:
Home-page: http://smb4k.berlios.de
Original-site:
Platforms: Linux and other Unices
Copying-policy: GNU Public License
End

@ -0,0 +1,22 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
SUBDIRS = icons core configdlg dialogs browser iconview listview searchdlg
# Main program
bin_PROGRAMS = smb4k
smb4k_SOURCES = main.cpp smb4k.cpp smb4ksystemtray.cpp
smb4k_LDADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(top_builddir)/smb4k/dialogs/libsmb4kdialogs.la $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KFILE) $(LIB_KPARTS) $(LIB_QT)
smb4k_LDFLAGS = $(all_libraries) $(KDE_RPATH)
KDE_ICON = smb4k
xdg_apps_DATA = smb4k.desktop
rcdir = $(kde_datadir)/smb4k
rc_DATA = smb4k_shell.rc
noinst_HEADERS = smb4ksystemtray.h

@ -0,0 +1,15 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = libsmb4knetworkbrowser.la
noinst_HEADERS = smb4knetworkbrowser_part.h smb4knetworkbrowser.h \
smb4knetworkbrowseritem.h smb4knetworkbrowsertooltip.h
libsmb4knetworkbrowser_la_SOURCES = smb4knetworkbrowser_part.cpp \
smb4knetworkbrowser.cpp smb4knetworkbrowseritem.cpp \
smb4knetworkbrowsertooltip.cpp
libsmb4knetworkbrowser_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(top_builddir)/smb4k/dialogs/libsmb4kdialogs.la $(LIB_KDECORE) \
$(LIB_KDEUI) $(KDE_PLUGIN) $(LIB_KPARTS) $(LIB_QT)
libsmb4knetworkbrowser_la_LDFLAGS = -module -no-undefined $(all_libraries)
partrcdir = $(kde_datadir)/smb4knetworkbrowserpart
partrc_DATA = smb4knetworkbrowser_part.rc

@ -0,0 +1,211 @@
/***************************************************************************
smb4knetworkbrowser - The network browser widget of Smb4K.
-------------------
begin : Mo Jan 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qheader.h>
#include <qtimer.h>
// KDE includes
#include <klocale.h>
// application specific includes
#include "smb4knetworkbrowser.h"
#include "smb4knetworkbrowseritem.h"
#include "smb4knetworkbrowsertooltip.h"
#include "../core/smb4ksettings.h"
Smb4KNetworkBrowser::Smb4KNetworkBrowser( QWidget *parent, const char *name )
: KListView( parent, name )
{
setRootIsDecorated( true );
setAllColumnsShowFocus( false );
setMouseTracking( true );
m_tooltip = NULL;
m_block_tooltip = false;
addColumn( i18n( "Network" ), -1 );
addColumn( i18n( "Type" ), -1 );
addColumn( i18n( "IP Address" ), -1 );
addColumn( i18n( "Comment" ), -1 );
// Add some connections:
connect( this, SIGNAL( expanded( QListViewItem * ) ),
this, SLOT( slotItemExpandedCollapsed( QListViewItem * ) ) );
connect( this, SIGNAL( collapsed( QListViewItem * ) ),
this, SLOT( slotItemExpandedCollapsed( QListViewItem * ) ) );
connect( this, SIGNAL( executed( QListViewItem * ) ),
this, SLOT( slotItemExecuted( QListViewItem * ) ) );
}
Smb4KNetworkBrowser::~Smb4KNetworkBrowser()
{
}
void Smb4KNetworkBrowser::blockToolTips( bool block )
{
if ( block )
{
delete m_tooltip;
m_tooltip = NULL;
}
m_block_tooltip = block;
}
void Smb4KNetworkBrowser::contentsMouseMoveEvent( QMouseEvent *e )
{
// Store the *global* position of the mouse:
m_pos = e->globalPos();
// Find the item over which the user moved the mouse:
Smb4KNetworkBrowserItem *item = static_cast<Smb4KNetworkBrowserItem *>( itemAt( viewport()->mapFromGlobal( m_pos ) ) );
if ( item )
{
// Check if we are on the root decoration:
bool on_root = true;
if ( viewport()->mapFromGlobal( m_pos ).x() > header()->sectionPos( header()->mapToIndex( 0 ) ) +
treeStepSize() * ( item->depth() + ( rootIsDecorated() ? 1 : 0 ) ) + itemMargin() ||
viewport()->mapFromGlobal( m_pos ).x() < header()->sectionPos( header()->mapToIndex( 0 ) ) )
{
on_root = false;
}
if ( !on_root )
{
if ( m_tooltip )
{
if ( m_tooltip->item() != item )
{
delete m_tooltip;
if ( !m_block_tooltip && hasMouse() && isExecuteArea( viewport()->mapFromGlobal( m_pos ) ) &&
Smb4KSettings::showNetworkItemToolTip() )
{
m_tooltip = new Smb4KNetworkBrowserToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
m_tooltip = NULL;
}
}
else
{
// Do nothing
}
}
else
{
if ( !m_block_tooltip && hasMouse() && isExecuteArea( viewport()->mapFromGlobal( m_pos ) ) &&
Smb4KSettings::showNetworkItemToolTip() )
{
m_tooltip = new Smb4KNetworkBrowserToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
// Do nothing
}
}
}
else
{
delete m_tooltip;
m_tooltip = NULL;
}
}
else
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
}
KListView::contentsMouseMoveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KNetworkBrowser::slotItemExpandedCollapsed( QListViewItem *item )
{
// Explicitly select the item, because this won't be
// done if the user clicked on the root decoration.
setSelected( item, true );
}
void Smb4KNetworkBrowser::slotItemExecuted( QListViewItem *item )
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
if ( item && item->isExpandable() )
{
setOpen( item, !item->isOpen() );
}
}
void Smb4KNetworkBrowser::slotShowToolTip()
{
Smb4KNetworkBrowserItem *item = static_cast<Smb4KNetworkBrowserItem *>( itemAt( viewport()->mapFromGlobal( m_pos ) ) );
if ( !m_block_tooltip && m_tooltip && hasMouse() &&
isExecuteArea( viewport()->mapFromGlobal( m_pos ) ) &&
Smb4KSettings::showNetworkItemToolTip() &&
(m_tooltip->item() == item) )
{
emit aboutToShowToolTip( item );
m_tooltip->showTip( m_pos );
}
else
{
delete m_tooltip;
m_tooltip = NULL;
}
}
#include "smb4knetworkbrowser.moc"

@ -0,0 +1,153 @@
/***************************************************************************
smb4knetworkbrowser - The network browser widget of Smb4K.
-------------------
begin : Mo Jan 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KNETWORKBROWSER_H
#define SMB4KNETWORKBROWSER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <klistview.h>
// forward declarations
class Smb4KNetworkBrowserItem;
class Smb4KNetworkBrowserToolTip;
class Smb4KNetworkBrowser : public KListView
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent widget
*
* @param name The widget name
*/
Smb4KNetworkBrowser( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KNetworkBrowser();
/**
* Enumeration for the columns in the list view.
*/
enum Columns{ Network = 0, Type = 1, IP = 2, Comment = 3 };
/**
* Returns the global position of the mouse with respect
* to the viewport.
*
* @returns the position of the mouse.
*/
const QPoint &mousePosition() { return m_pos; }
/**
* Returns a pointer to the current tool tip or NULL, if there
* is no tool tip at the moment. Please note, that the tool tip
* is generated 2 sec before it is shown.
*
* @returns a pointer to the current tool tip.
*/
Smb4KNetworkBrowserToolTip *tooltip() { return m_tooltip; }
/**
* Block the showing of tool tips. If @p block is set to TRUE, the
* current tool tip gets deleted (if there is one) and no tool tip
* will be shown until @p block is reset to FALSE.
*
* @param block Set this parameter to TRUE to block the showing
* of tool tips.
*/
void blockToolTips( bool block );
signals:
/**
* This signal is emitted when the tool tip is about to be shown.
*
* @param item The item for which the tool tip should be shown.
*/
void aboutToShowToolTip( Smb4KNetworkBrowserItem *item );
/**
* This signal is emitted when the tool tip has been closed.
*/
void closedToolTip();
protected:
/**
* Reimplemented from QListView. This slot keeps track of the
* mouse position and handles the tool tips.
*
* @param e The mouse event
*/
void contentsMouseMoveEvent( QMouseEvent *e );
protected slots:
/**
* This slot is called whenever a QListViewItem is expanded or
* collapsed. At the moment it is only used to select the item.
*
* @param item The list view item that has been
* expanded/collapsed.
*/
void slotItemExpandedCollapsed( QListViewItem *item );
/**
* This slot is called when the user executed an item. It is used
* to open the item if it is expandable.
*
* @param item The item that has been executed.
*/
void slotItemExecuted( QListViewItem *item );
/**
* This slot shows the tool tip.
*/
void slotShowToolTip();
private:
/**
* The global position of the mouse with respect to the widget.
*/
QPoint m_pos;
/**
* The tool tip for the network browser
*/
Smb4KNetworkBrowserToolTip *m_tooltip;
/**
* Block tool tips
*/
bool m_block_tooltip;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,377 @@
/***************************************************************************
smb4knetworkbrowser_part - This Part encapsulates the network
browser of Smb4K.
-------------------
begin : Fr Jan 5 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KNETWORKBROWSERPART_H
#define SMB4KNETWORKBROWSERPART_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kactionclasses.h>
#include <kparts/part.h>
#include <kparts/factory.h>
// Qt includes
#include <qptrlist.h>
#include <qlistview.h>
// forward declarations
class Smb4KNetworkBrowser;
class Smb4KNetworkBrowserItem;
class Smb4KWorkgroupItem;
class Smb4KHostItem;
class Smb4KShareItem;
/**
* This is one of the parts of Smb4K. It contains the network browser.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KNetworkBrowserPart : public KParts::Part
{
Q_OBJECT
public:
/**
* Mode enumeration
*/
enum Mode { Normal, KonqPlugin };
/**
* The constructor.
*
* @param parentWidget The parent widget
*
* @param widgetName The name the widget should have
*
* @param parent The parent object
*
* @param name The name this object should have
*
* @param mode Determines in which mode the KPart should be started
*/
Smb4KNetworkBrowserPart( QWidget *parentWidget = 0,
const char *widgetName = 0,
QObject *parent = 0,
const char *name = 0,
Mode mode = Normal );
/**
* The destructor.
*/
virtual ~Smb4KNetworkBrowserPart();
protected:
/**
* Reimplemented from KParts::Part.
*/
void customEvent( QCustomEvent *e );
protected slots:
/**
* This slot is called if the user requests the context menu. It shows
* the menu with the actions defined for the widget.
*
* @param item The item for which the popup menu has been
* requested or NULL.
*
* @param pos The position where user clicked.
*
* @param col The column where the user clicked.
*/
void slotContextMenuRequested( QListViewItem *item, const QPoint &pos, int col );
/**
* Is called when the selection changed. This slot takes care of the
* actions being enabled or disabled accordingly. All widget specific
* stuff has to be done in the browser widget itself.
*
* @param item The selection list view item.
*/
void slotSelectionChanged( QListViewItem *item );
/**
* Is called when the user pressed a mouse button somewhere in the widget.
* In addition to Smb4KNetworkBrowserPart::slotSelectionChanged() this slot
* takes care of the actions being enabled or disabled accordingly. All
* widget specific stuff has to be done in the browser widget itself.
*
* @param item The selection list view item.
*/
void slotPressed( QListViewItem *item );
/**
* This slot is called when an item of the browser's list view has been opened.
* It is used to invoke the functions of the scanner that need to be run.
*
* @param item The list view item that has been opened.
*/
void slotItemExpanded( QListViewItem *item );
/**
* This slot is called when an item of the browser's list view has been closed.
*
* @param item The list view item that has been closed.
*/
void slotItemCollapsed( QListViewItem *item );
/**
* This slot is invoked when the user executed an item. It is used to mount
* shares.
*
* @param item The list view item that has been executed.
*/
void slotItemExecuted( QListViewItem *item );
/**
* This slot is called when the user moved the mouse over an @p item in the
* network browser's list view and a tool tip is about to be shown. It will
* initiate any actions that have to be taken by the scanner to complete
* the information on the network items shown in the browser.
*
* @param item The item for which the additional info should
* be retrieved
*/
void slotAboutToShowToolTip( Smb4KNetworkBrowserItem *item );
/**
* This slot receives the workgroups/domains found by the scanner. It takes
* a list of workgroup items @p list and inserts the respective workgroups
* into the browser window. Obsolete items will be deleted from the network
* browser.
*
* @param list A list of Smb4KWorkgroupItem objects
*/
void slotWorkgroups( const QValueList<Smb4KWorkgroupItem *> &list );
/**
* This slot receives the list of workgroup/domain members that were found
* by the scanner. It takes this @p list and inserts it into the list view.
* The parent of the items is the workgroup/domain item with the name
* @p workgroup. Obsolete items will be deleted from the network browser.
*
* @param workgroup The workgroup where the hosts belong
*
* @param list A list of Smb4KHostItem objects
*/
void slotWorkgroupMembers( const QString &workgroup, const QValueList<Smb4KHostItem *> &list );
/**
* This slot receives the list of shared resources a host provides. It takes
* this @p list and inserts its items as children of @p host into the list
* view. Obsolete items will be deleted from the network browser.
*
* @param host The host where the shares belong
*
* @param list The list of shares that belong to @p host
*/
void slotShares( const QString &host, const QValueList<Smb4KShareItem *> &list );
/**
* This slot takes a Smb4KHostItem object @p item, reads the IP address entry
* from it and updates the list view item representing the host with it.
*
* @param item A Smb4KHostItem with an updated IP address.
*/
void slotAddIPAddress( Smb4KHostItem *item );
/**
* This slot adds additional information to a browser item. It takes an
* Smb4KHostItem @p item, searches the assossiated browser item and updates its
* contents.
*
* @param item A Smb4KHostItem with updated contents.
*/
void slotAddInformation( Smb4KHostItem *item );
/**
* This slots is connected to the Smb4KScanner::hostAdded() signal and inserts
* a single host in the list view. If the host is already present, nothing is
* done.
*
* @param item A Smb4KHostItem that is to be added to the
* list view.
*/
void slotInsertHost( Smb4KHostItem *item );
/**
* Rescan the network. This slot is connected to the 'Rescan' action.
*/
void slotRescan();
/**
* Abort a network scan. This slot is connected to the 'Abort' action.
*/
void slotAbort();
/**
* Manually mount a share. This slot is connected to the 'Mount Manually'
* action and opens a mount dialog.
*/
void slotMountManually();
/**
* Provide authentication for the current network object. This slot is
* connected to the 'Authentication' action.
*/
void slotAuthentication();
/**
* Provide custom options for a server or share. This slot is connected
* to the 'Custom Options' action.
*/
void slotCustomOptions();
/**
* Bookmark a remote share. This slot is connected to the 'Add Bookmark'
* action.
*/
void slotBookmark();
/**
* Preview a share. This slot is connected to the 'Preview' action.
*/
void slotPreview();
/**
* Print a document on a remote printer. This slot is connected to the
* 'Print File' action.
*/
void slotPrint();
/**
* Mount a remote share. This slot is connected to the 'Mount' action.
*/
void slotMount();
/**
* Unmount a share. This slot is only relevant in the Konqueror plugin
* mode.
*/
void slotUnmount();
/**
* This slot is invoked by the Smb4KMounter::updated() signal and changes
* the text and icon of all shares that are already mounted.
*/
void slotMarkMountedShares();
/**
* This slot is connected to the Smb4KCore::runStateChanged() signal and
* is used to enable/disable actions.
*/
void slotRunStateChanged();
private:
/**
* Set up the actions
*/
void setupActions();
/**
* Load settings for the widget or the actions.
*/
void loadSettings();
/**
* The action menu
*/
KActionMenu *m_menu;
/**
* The network browser widget
*/
Smb4KNetworkBrowser *m_widget;
/**
* Determines with which mode the KPart will be started
*/
Mode m_mode;
};
class KInstance;
class KAboutData;
class Smb4KNetworkBrowserPartFactory : public KParts::Factory
{
Q_OBJECT
public:
/**
* The constructor
*/
Smb4KNetworkBrowserPartFactory();
/**
* The destructor
*/
virtual ~Smb4KNetworkBrowserPartFactory();
/**
* Reimplemented from KParts::Factory. This function is used to
* create a part object.
*
* @param parentWidget The parent of the part's widget.
*
* @param widgetName The name of the part's widget.
*
* @param parent The parent of the part.
*
* @param name The name of the part.
*
* @param classname The class name of the part. This should be "KParts::Part".
*
* @param args A list of additional arguments. They have to be provided as
* name="value" pairs. At the moment this function understands
* the following pairs:
* konqplugin="true"|"false".
*/
virtual KParts::Part *createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const char *classname, const QStringList &args = QStringList() );
/**
* The instance
*/
static KInstance *instance();
private:
/**
* The factory's instance.
*/
static KInstance *m_instance;
/**
* The factory's KAboutData object
*/
static KAboutData *m_about;
};
#endif

@ -0,0 +1,31 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="smb4knetworkbrowser_part" version="1">
<MenuBar>
<Menu name="network"><text>&amp;Network</text>
<Action name="rescan_action"/>
<Action name="abort_action"/>
<Separator/>
<Action name="mount_manually_action"/>
<Separator/>
<Action name="askpass_action"/>
<Action name="custom_action"/>
<Action name="bookmark_action"/>
<Action name="preview_action"/>
<Action name="print_action"/>
<Action name="mount_action"/>
</Menu>
</MenuBar>
<ToolBar name="networkToolBar">
<Action name="rescan_action"/>
<Action name="abort_action"/>
<Separator/>
<Action name="mount_manually_action"/>
<Separator/>
<Action name="askpass_action"/>
<Action name="custom_action"/>
<Action name="bookmark_action"/>
<Action name="preview_action"/>
<Action name="print_action"/>
<Action name="mount_action"/>
</ToolBar>
</kpartgui>

@ -0,0 +1,228 @@
/***************************************************************************
smb4knetworkbrowseritem - Smb4K's network browser list item.
-------------------
begin : Mo Jan 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qpainter.h>
// KDE includes
#include <kiconloader.h>
#include <kicontheme.h>
// application specific includes
#include "smb4knetworkbrowseritem.h"
Smb4KNetworkBrowserItem::Smb4KNetworkBrowserItem( QListView *parent, Smb4KWorkgroupItem *item )
: KListViewItem( parent, item->name() ), m_type( Workgroup ), m_workgroup( *item ),
m_mounted( false )
{
setIcon();
}
Smb4KNetworkBrowserItem::Smb4KNetworkBrowserItem( QListViewItem *parent, Smb4KHostItem *item )
: KListViewItem( parent, item->name(), QString::null, item->ip(), item->comment() ),
m_type( Host ), m_host( *item ), m_mounted( false )
{
setIcon();
}
Smb4KNetworkBrowserItem::Smb4KNetworkBrowserItem( QListViewItem *parent, Smb4KShareItem *item )
: KListViewItem( parent, item->name(), item->plainType(), QString::null, item->comment() ),
m_type( Share ), m_share( *item ), m_mounted( false )
{
setIcon();
}
Smb4KNetworkBrowserItem::~Smb4KNetworkBrowserItem()
{
}
void Smb4KNetworkBrowserItem::setIcon()
{
switch ( m_type )
{
case Workgroup:
{
m_desktop_icon = DesktopIcon( "network_local" );
setPixmap( 0, SmallIcon( "network_local" ) );
break;
}
case Host:
{
m_desktop_icon = DesktopIcon( "server" );
setPixmap( 0, SmallIcon( "server" ) );
break;
}
case Share:
{
if ( m_share.isPrinter() )
{
m_desktop_icon = DesktopIcon( "printer1" );
setPixmap( 0, SmallIcon( "printer1" ) );
}
else
{
if ( m_mounted )
{
m_desktop_icon = DesktopIcon( "folder_open", 0, KIcon::ActiveState );
setPixmap( 0, SmallIcon( "folder_open", 0, KIcon::ActiveState ) );
}
else
{
m_desktop_icon = DesktopIcon( "folder", 0, KIcon::DefaultState );
setPixmap( 0, SmallIcon( "folder", 0, KIcon::DefaultState ) );
}
}
break;
}
default:
{
break;
}
}
}
Smb4KNetworkBrowserItem::ItemType Smb4KNetworkBrowserItem::type()
{
return m_type;
}
Smb4KWorkgroupItem *Smb4KNetworkBrowserItem::workgroupItem()
{
return (m_type == Workgroup ? &m_workgroup : NULL);
}
Smb4KHostItem *Smb4KNetworkBrowserItem::hostItem()
{
return (m_type == Host ? &m_host : NULL);
}
Smb4KShareItem *Smb4KNetworkBrowserItem::shareItem()
{
return (m_type == Share ? &m_share : NULL);
}
void Smb4KNetworkBrowserItem::update( Smb4KWorkgroupItem *item )
{
m_workgroup = *item;
}
void Smb4KNetworkBrowserItem::update( Smb4KHostItem *item )
{
m_host = *item;
if ( !m_host.ip().isEmpty() && QString::compare( text( IP ).stripWhiteSpace(), m_host.ip() ) != 0 )
{
setText( IP, m_host.ip() );
}
if ( QString::compare( text( Comment ).stripWhiteSpace(), m_host.comment() ) != 0 )
{
setText( Comment, m_host.comment() );
}
}
void Smb4KNetworkBrowserItem::update( Smb4KShareItem *item )
{
m_share = *item;
if ( !m_share.comment().isEmpty() && QString::compare( text( Comment ).stripWhiteSpace(), m_share.comment() ) != 0 )
{
setText( Comment, m_share.comment() );
}
}
bool Smb4KNetworkBrowserItem::isPrinter()
{
bool is_printer = false;
if ( m_type == Share )
{
is_printer = m_share.isPrinter();
}
return is_printer;
}
void Smb4KNetworkBrowserItem::setMounted( bool mounted )
{
if ( m_type == Share && QString::compare( m_share.plainType(), "Disk" ) == 0 )
{
m_mounted = mounted;
setIcon();
}
else
{
// Do nothing
}
}
bool Smb4KNetworkBrowserItem::isMounted()
{
return m_mounted;
}
void Smb4KNetworkBrowserItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
QFont f( p->font() );
QColorGroup colorgrp( cg );
if ( m_type == Share && m_mounted )
{
f.setItalic( true );
}
else
{
f.setItalic( false );
}
if ( m_type == Host && m_host.isMaster() )
{
colorgrp.setColor( QColorGroup::Text, Qt::darkBlue );
}
else
{
colorgrp.setColor( QColorGroup::Text, cg.text() );
}
p->setFont( f );
QListViewItem::paintCell( p, colorgrp, column, width, align );
}

@ -0,0 +1,222 @@
/***************************************************************************
smb4knetworkbrowseritem - Smb4K's network browser list item.
-------------------
begin : Mo Jan 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KNETWORKBROWSERITEM_H
#define SMB4KNETWORKBROWSERITEM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qpixmap.h>
// KDE includes
#include <klistview.h>
// application specific includes
#include "../core/smb4knetworkitems.h"
class Smb4KNetworkBrowser;
class Smb4KNetworkBrowserItem : public KListViewItem
{
public:
/**
* The constructor for toplevel (workgroup) items.
*
* @param parent The parent list view.
*
* @param item The Smb4KWorkgroupItem that carries all the data
* needed to set up a "workgroup item".
*/
Smb4KNetworkBrowserItem( QListView *parent, Smb4KWorkgroupItem *item );
/**
* The constructor for the host items.
*
* @param parent The parent list view item.
*
* @param item The Smb4KHostItem that carries all the data.
*/
Smb4KNetworkBrowserItem( QListViewItem *parent, Smb4KHostItem *item );
/**
* The constructor for the share items.
*
* @param parent The parent list view item.
*
* @param item The Smb4KShareItem that carries all the data.
*/
Smb4KNetworkBrowserItem( QListViewItem *parent, Smb4KShareItem *item );
/**
* The destructor.
*/
virtual ~Smb4KNetworkBrowserItem();
/**
* Enumeration that determines the type of the item.
*/
enum ItemType{ Workgroup, Host, Share };
/**
* This function returns the type of the item according to the ItemType
* enumeration.
*
* @returns the type of the item.
*/
Smb4KNetworkBrowserItem::ItemType type();
/**
* This function returns a pointer to the Smb4KWorkgroupItem object if it
* is present or NULL if it is not.
*
* @returns a pointer to the workgroup item or NULL.
*/
Smb4KWorkgroupItem *workgroupItem();
/**
* This function returns a pointer to the Smb4KHostItem object if it
* is present or NULL if it is not.
*
* @returns a pointer to the host item or NULL.
*/
Smb4KHostItem *hostItem();
/**
* This function returns a pointer to the Smb4KShareItem object if it
* is present or NULL if it is not.
*
* @returns a pointer to the share item or NULL.
*/
Smb4KShareItem *shareItem();
/**
* This function updates the internal Smb4KWorkgroupItem object.
*
* @param item A Smb4KWorkgroupItem object
*/
void update( Smb4KWorkgroupItem *item );
/**
* This function updates the internal Smb4KHostItem object and
* changes the text that's being displayed in the browser. Use this,
* if you have to alter the item in the browser.
*
* @param item A Smb4KHostItem
*/
void update( Smb4KHostItem *item );
/**
* This function updates the internal Smb4KShareItem object and
* changes the text that's being displayed in the browser. Use this,
* if you have to alter the item in the browser.
*
* @param item A Smb4KShareItem
*/
void update( Smb4KShareItem *item );
/**
* This is a convenience function. It returns TRUE if the item is a
* printer share and FALSE otherwise.
*
* @returns TRUE if the item is a printer share and FALSE otherwise.
*/
bool isPrinter();
/**
* Tell the item that the share it represents is mounted. The icon will be
* changed by this function and the item text will be set to italic by
* Smb4KNetworkBrowserItem::paintCell().
*
* @param mounted TRUE if the share is mounted and FALSE otherwise
*/
void setMounted( bool mounted = true );
/**
* Tells whether the respective share is shown as mounted or not. For non-share
* items this function will always return FALSE.
*
* @returns TRUE if the share is mounted and FALSE otherwise.
*/
bool isMounted();
/**
* Returns the icon of this item in "Desktop" size.
*
* @returns a pixmap
*/
const QPixmap &desktopIcon() { return m_desktop_icon; }
protected:
/**
* Reimplemented from QListViewItem.
*/
void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
private:
/**
* This function sets the icon of the item according to
* the type and other factors.
*/
void setIcon();
/**
* The type of the item.
*/
ItemType m_type;
/**
* This enumeration enumerates the columns of the item.
*/
enum Columns{ Network = 0, Type = 1, IP = 2, Comment = 3 };
/**
* The workgroup item
*/
Smb4KWorkgroupItem m_workgroup;
/**
* The host item
*/
Smb4KHostItem m_host;
/**
* The share item
*/
Smb4KShareItem m_share;
/**
* Tells us that the share item is mounted
*/
bool m_mounted;
/**
* The icon in "DesktopIcon" format
*/
QPixmap m_desktop_icon;
};
#endif

@ -0,0 +1,378 @@
/***************************************************************************
smb4knetworkbrowsertooltip - Tool tip for the network browser.
-------------------
begin : Sa Jan 20 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qtooltip.h>
#include <qdesktopwidget.h>
#include <qapplication.h>
#include <qtimer.h>
// KDE includes
#include <klocale.h>
// application specific includes
#include "smb4knetworkbrowsertooltip.h"
#include "smb4knetworkbrowseritem.h"
Smb4KNetworkBrowserToolTip::Smb4KNetworkBrowserToolTip( Smb4KNetworkBrowserItem *item )
: QLabel( 0, "NetworkBrowserToolTip", WStyle_StaysOnTop | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM | WDestructiveClose ), m_item( item )
{
setPalette( QToolTip::palette() );
setLineWidth( 1 );
setMidLineWidth( 1 );
setFrameShape( Box );
setFrameShadow( Plain );
setMouseTracking( true );
m_layout = new QGridLayout( this );
m_layout->setMargin( 10 );
m_layout->setSpacing( 3 );
// We will set up the tip in the showTip() function.
}
Smb4KNetworkBrowserToolTip::~Smb4KNetworkBrowserToolTip()
{
// Never touch the Smb4KNetworkBrowserItem object here
}
void Smb4KNetworkBrowserToolTip::showTip( const QPoint &pos )
{
if ( !m_item || isShown() )
{
return;
}
setupTip();
adjustSize();
QPoint p( pos );
QDesktopWidget *d = QApplication::desktop();
if ( p.x() + width() > d->width() )
{
p.setX( p.x() - width() - 5 );
}
else
{
p.setX( p.x() + 5 );
}
if ( p.y() + height() > d->height() )
{
p.setY( p.y() - height() - 5 );
}
else
{
p.setY( p.y() + 5 );
}
setGeometry( p.x(), p.y(), width(), height() );
polish();
show();
QTimer::singleShot( 10000, this, SLOT( slotHideToolTip() ) );
}
void Smb4KNetworkBrowserToolTip::setupTip()
{
switch ( m_item->type() )
{
case Smb4KNetworkBrowserItem::Workgroup:
{
QLabel *workgroup_label = new QLabel( i18n( "Workgroup:" ), this );
QLabel *workgroup = new QLabel( m_item->workgroupItem()->name() , this );
QString master_label_entry = m_item->workgroupItem()->hasPseudoMaster() ? i18n( "Pseudo master browser:" ) : i18n( "Master browser:" );
QLabel *master_label = new QLabel( master_label_entry, this );
QString master_entry = m_item->workgroupItem()->masterIP().isEmpty() ?
(m_item->workgroupItem()->master().isEmpty() ? i18n( "Unknown" ) : m_item->workgroupItem()->master()) :
m_item->workgroupItem()->master() + " ("+m_item->workgroupItem()->masterIP()+")";
QLabel *master = new QLabel( master_entry, this, "MasterBrowser" );
m_layout->addWidget( workgroup_label, 0, 1, 0 );
m_layout->addWidget( workgroup, 0, 2, 0 );
m_layout->addWidget( master_label, 1, 1, 0 );
m_layout->addWidget( master, 1, 2, 0 );
break;
}
case Smb4KNetworkBrowserItem::Host:
{
QLabel *host_label = new QLabel( i18n( "Host:" ), this );
QLabel *host = new QLabel( m_item->hostItem()->name(), this );
QLabel *comment_label = new QLabel( i18n( "Comment:" ), this );
QLabel *comment = new QLabel( m_item->hostItem()->comment(), this );
QLabel *ip_label = new QLabel( i18n( "IP address:" ), this );
QString ip_entry = m_item->hostItem()->ip().isEmpty() ? i18n( "Unknown" ) : m_item->hostItem()->ip();
QLabel *ip_address = new QLabel( ip_entry, this, "IPAddress" );
QLabel *os_label = new QLabel( i18n( "Operating system:" ), this );
QLabel *operating_system = new QLabel( m_item->hostItem()->osString().isEmpty() ? i18n( "Unknown" ) :
m_item->hostItem()->osString(), this, "OSString" );
QLabel *server_label = new QLabel( i18n( "Server string:" ), this );
QLabel *server_string = new QLabel( m_item->hostItem()->serverString().isEmpty() ? i18n( "Unknown" ) :
m_item->hostItem()->serverString(), this, "ServerString" );
QFrame *line = new QFrame( this );
line->setLineWidth( 1 );
line->setMidLineWidth( 0 );
line->setFixedWidth( 100 );
line->setFrameShape( QFrame::HLine );
line->setFrameShadow( QFrame::Plain );
QLabel *workgroup_label = new QLabel( i18n( "Workgroup:" ), this );
QLabel *workgroup = new QLabel( m_item->hostItem()->workgroup(), this );
Smb4KWorkgroupItem *workgroup_item = static_cast<Smb4KNetworkBrowserItem *>( m_item->parent() )->workgroupItem();
QLabel *master_label = new QLabel( i18n( "Master browser:" ), this );
QLabel *master_yes_no = new QLabel( (workgroup_item && !workgroup_item->master().isEmpty()) ?
workgroup_item->master() : i18n( "Unknown" ), this );
m_layout->addWidget( host_label, 0, 1, 0 );
m_layout->addWidget( host, 0, 2, 0 );
m_layout->addWidget( comment_label, 1, 1, 0 );
m_layout->addWidget( comment, 1, 2, 0 );
m_layout->addWidget( ip_label, 2, 1, 0 );
m_layout->addWidget( ip_address, 2, 2, 0 );
m_layout->addWidget( os_label, 3, 1, 0 );
m_layout->addWidget( operating_system, 3, 2, 0 );
m_layout->addWidget( server_label, 4, 1, 0 );
m_layout->addWidget( server_string, 4, 2, 0 );
m_layout->addMultiCellWidget( line, 5, 5, 1, 2, Qt::AlignCenter );
m_layout->addWidget( workgroup_label, 6, 1, 0 );
m_layout->addWidget( workgroup, 6, 2, 0 );
m_layout->addWidget( master_label, 7, 1, 0 );
m_layout->addWidget( master_yes_no, 7, 2, 0 );
break;
}
case Smb4KNetworkBrowserItem::Share:
{
QLabel *share_label = new QLabel( i18n( "Share:" ), this );
QLabel *share = new QLabel( m_item->shareItem()->name(), this );
QLabel *comment_label = new QLabel( i18n( "Comment:" ), this );
QLabel *comment = new QLabel( m_item->shareItem()->comment(), this );
QLabel *type_label = new QLabel( i18n( "Type:" ), this );
QLabel *type = new QLabel( m_item->shareItem()->translatedType(), this );
QLabel *mounted_label = NULL;
QLabel *mounted = NULL;
if ( !m_item->isPrinter() )
{
mounted_label = new QLabel( i18n( "Mounted:" ), this );
mounted = new QLabel( m_item->isMounted() ? i18n( "Yes" ) : i18n( "No" ), this );
}
QFrame *line = new QFrame( this );
line->setLineWidth( 1 );
line->setMidLineWidth( 0 );
line->setFixedWidth( 100 );
line->setFrameShape( QFrame::HLine );
line->setFrameShadow( QFrame::Plain );
QLabel *host_label = new QLabel( i18n( "Host:" ), this );
QLabel *host = new QLabel( m_item->shareItem()->host(), this );
Smb4KHostItem *host_item = static_cast<Smb4KNetworkBrowserItem *>( m_item->parent() )->hostItem();
QLabel *ip_label = new QLabel( i18n( "IP address:" ), this );
QLabel *ip_address = new QLabel( (host_item && !host_item->ip().isEmpty()) ?
host_item->ip() : i18n( "Unknown" ), this, "IPAddress" );
m_layout->addWidget( share_label, 0, 1, 0 );
m_layout->addWidget( share, 0, 2, 0 );
m_layout->addWidget( comment_label, 1, 1, 0 );
m_layout->addWidget( comment, 1, 2, 0 );
m_layout->addWidget( type_label, 2, 1, 0 );
m_layout->addWidget( type, 2, 2, 0 );
if ( !m_item->isPrinter() )
{
m_layout->addWidget( mounted_label, 3, 1, 0 );
m_layout->addWidget( mounted, 3, 2, 0 );
m_layout->addMultiCellWidget( line, 4, 4, 1, 2, Qt::AlignCenter );
m_layout->addWidget( host_label, 5, 1, 0 );
m_layout->addWidget( host, 5, 2, 0 );
m_layout->addWidget( ip_label, 6, 1, 0 );
m_layout->addWidget( ip_address, 6, 2, 0 );
}
else
{
m_layout->addMultiCellWidget( line, 3, 3, 1, 2, Qt::AlignCenter );
m_layout->addWidget( host_label, 4, 1, 0 );
m_layout->addWidget( host, 4, 2, 0 );
m_layout->addWidget( ip_label, 5, 1, 0 );
m_layout->addWidget( ip_address, 5, 2, 0 );
}
break;
}
default:
{
break;
}
}
QLabel *pix_label = new QLabel( this );
pix_label->setPixmap( m_item->desktopIcon() );
m_layout->addMultiCellWidget( pix_label, 0, m_layout->numRows(), 0, 0, Qt::AlignCenter );
}
void Smb4KNetworkBrowserToolTip::update()
{
// This function updates a tool tip that
// is shown. So, if the tool tip exists, but
// is not shown, stop here.
if ( !isShown() )
{
return;
}
switch ( m_item->type() )
{
case Smb4KNetworkBrowserItem::Workgroup:
{
QLabel *master_label = static_cast<QLabel *>( child( "MasterBrowser", "QLabel", true ) );
if ( master_label )
{
QString master_string = m_item->workgroupItem()->masterIP().isEmpty() ?
m_item->workgroupItem()->master() :
m_item->workgroupItem()->master() + " ("+m_item->workgroupItem()->masterIP()+")";
master_label->setText( master_string );
}
break;
}
case Smb4KNetworkBrowserItem::Host:
{
QLabel *os_label = static_cast<QLabel *>( child( "OSString", "QLabel", true ) );
QLabel *server_label = static_cast<QLabel *>( child( "ServerString", "QLabel", true ) );
QLabel *ip_label = static_cast<QLabel *>( child( "IPAddress", "QLabel", true ) );
if ( os_label )
{
QString os_string = m_item->hostItem()->osString().isEmpty() ?
i18n( "Unknown" ) :
m_item->hostItem()->osString();
os_label->setText( os_string );
}
if ( server_label )
{
QString server_string = m_item->hostItem()->serverString().isEmpty() ?
i18n( "Unknown" ) :
m_item->hostItem()->serverString();
server_label->setText( server_string );
}
if ( ip_label )
{
QString ip_string = m_item->hostItem()->ip().isEmpty() ?
i18n( "Unknown" ) :
m_item->hostItem()->ip();
ip_label->setText( ip_string );
}
break;
}
case Smb4KNetworkBrowserItem::Share:
{
QLabel *ip_label = static_cast<QLabel *>( child( "IPAddress", "QLabel", true ) );
if ( ip_label )
{
Smb4KHostItem *host = static_cast<Smb4KNetworkBrowserItem *>( m_item->parent() )->hostItem();
QString ip_string;
if ( host )
{
ip_string = (host && !host->ip().isEmpty()) ?
host->ip() :
i18n( "Unknown" );
}
else
{
ip_string = i18n( "Unknown" );
}
ip_label->setText( ip_string );
}
break;
}
default:
{
break;
}
}
}
void Smb4KNetworkBrowserToolTip::mousePressEvent( QMouseEvent *e )
{
hide();
QLabel::mousePressEvent( e );
}
void Smb4KNetworkBrowserToolTip::leaveEvent( QEvent *e )
{
hide();
QLabel::leaveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KNetworkBrowserToolTip::slotHideToolTip()
{
if ( isShown() )
{
hide();
}
}
#include "smb4knetworkbrowsertooltip.moc"

@ -0,0 +1,122 @@
/***************************************************************************
smb4knetworkbrowsertooltip - Tool tip for the network browser.
-------------------
begin : Sa Jan 20 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KNETWORKBROWSERTOOLTIP_H
#define SMB4KNETWORKBROWSERTOOLTIP_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qlabel.h>
#include <qlayout.h>
// Forward declarations:
class Smb4KNetworkBrowserItem;
/**
* This class provides the tool tip for the network browser
* of Smb4K. It shows information about the associated share.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KNetworkBrowserToolTip : public QLabel
{
Q_OBJECT
public:
/**
* The constructor
*
* @param item The Smb4KNetworkBrowserItem object for which
* a tool tip should be shown.
*/
Smb4KNetworkBrowserToolTip( Smb4KNetworkBrowserItem *item );
/**
* The destructor
*/
~Smb4KNetworkBrowserToolTip();
/**
* Show the tool tip. Please note that the tool tip will not be shown
* exactly at position @p pos but with a displacement of 5 pixels in x-
* and y-direction.
*/
void showTip( const QPoint &pos );
/**
* If you need to update the tool tip while it is shown, this is the function
* you want to use. It rereads the entries from the assossiated
* Smb4KNetworkBrowserItem object and modifies the tool tip if changes happened.
*/
void update();
/**
* Returns the Smb4KNetworkBrowserItem object for which the tool tip
* should be shown.
*
* @returns a pointer to a Smb4KNetworkBrowserItem object.
*/
Smb4KNetworkBrowserItem *item() { return m_item; }
protected:
/**
* Reimplemented from QLabel.
*/
void mousePressEvent( QMouseEvent *e );
/**
* Reimplemented from QLabel.
*/
void leaveEvent( QEvent *e );
protected slots:
/**
* This slot hides the tool tip after 10 sec.
*/
void slotHideToolTip();
private:
/**
* The pointer to the Smb4KNetworkBrowserItem object
*/
Smb4KNetworkBrowserItem *m_item;
/**
* The layout for the tool tip
*/
QGridLayout *m_layout;
/**
* Set up the tool tip
*/
void setupTip();
};
#endif

@ -0,0 +1,12 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = libsmb4kconfigdialog.la
noinst_HEADERS = smb4kauthoptions.h smb4kconfigdialog.h smb4knetworkoptions.h \
smb4krsyncoptions.h smb4ksambaoptions.h smb4kshareoptions.h smb4ksuperuseroptions.h \
smb4kuserinterfaceoptions.h
libsmb4kconfigdialog_la_SOURCES = smb4kauthoptions.cpp smb4kconfigdialog.cpp \
smb4knetworkoptions.cpp smb4krsyncoptions.cpp smb4ksambaoptions.cpp smb4kshareoptions.cpp \
smb4ksuperuseroptions.cpp smb4kuserinterfaceoptions.cpp
libsmb4kconfigdialog_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(LIB_KDECORE) $(LIB_KDEUI) $(LIB_QT)
libsmb4kconfigdialog_la_LDFLAGS = -module $(KDE_PLUGIN)

@ -0,0 +1,135 @@
/***************************************************************************
smb4kauthoptions - The configuration page for the authentication
settings of Smb4K
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qcheckbox.h>
#include <qlayout.h>
#include <qgroupbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qwhatsthis.h>
// KDE includes
#include <klocale.h>
#include <klineedit.h>
// application specific includes
#include "smb4kauthoptions.h"
Smb4KAuthOptions::Smb4KAuthOptions( QWidget *parent, const char *name )
: QWidget( parent, name )
{
//
// Default Authentication
//
QGridLayout *grid = new QGridLayout( this );
grid->setSpacing( 10 );
QButtonGroup *password_group = new QButtonGroup( 1, QButtonGroup::Horizontal,
i18n( "Password Storage" ), this );
QCheckBox *use_wallet = new QCheckBox( i18n( "Save the authentication data in a wallet" ),
password_group, "kcfg_UseWallet" );
(void) new QCheckBox( i18n( "If no wallet is used, remember authentication data during run time" ),
password_group, "kcfg_RememberPasswords" );
QGroupBox *login_box = new QGroupBox( 1, Qt::Horizontal, i18n( "Default Login" ),
this, "DefaultLoginBox" );
// login_box->setInsideMargin( 10 );
QCheckBox *default_auth = new QCheckBox( i18n( "Use default login" ),
login_box, "kcfg_UseDefaultLogin" );
QWidget *auth_widget = new QWidget( login_box, "DefaultAuthWidget" );
QGridLayout *auth_grid = new QGridLayout( auth_widget );
auth_grid->setSpacing( 5 );
QLabel *login = new QLabel( i18n( "User:" ), auth_widget );
KLineEdit *default_login = new KLineEdit( auth_widget, "DefaultUserName" );
default_login->setMinimumWidth( 150 );
QWhatsThis::add( default_login, i18n( "This login name is used by default to authenticate to a remote server." ) );
QLabel *password = new QLabel( i18n( "Password:" ), auth_widget );
KLineEdit *default_password = new KLineEdit( auth_widget, "DefaultPassword" );
default_password->setEchoMode( KLineEdit::Password );
default_password->setMinimumWidth( 150 );
QWhatsThis::add( default_password, i18n( "This password is used by default to authenticate to a remote server. It may be empty." ) );
auth_grid->addWidget( login, 0, 0 );
auth_grid->addWidget( default_login, 0, 1 );
auth_grid->addWidget( password, 1, 0 );
auth_grid->addWidget( default_password, 1, 1 );
QSpacerItem *spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
grid->addWidget( password_group, 0, 0, 0 );
grid->addWidget( login_box, 1, 0, 0 );
grid->addItem( spacer2, 2, 0 );
connect( use_wallet, SIGNAL( stateChanged( int ) ),
this, SLOT( slotKWalletButtonState( int ) ) );
connect( default_auth, SIGNAL( stateChanged( int ) ),
this, SLOT( slotDefaultAuthButtonState( int ) ) );
slotKWalletButtonState( use_wallet->state() );
slotDefaultAuthButtonState( default_auth->state() );
}
Smb4KAuthOptions::~Smb4KAuthOptions()
{
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KAuthOptions::slotKWalletButtonState( int state )
{
if ( state == QCheckBox::On )
{
static_cast<QCheckBox *>( child( "DefaultLoginBox", "QGroupBox", true ) )->setEnabled( true );
}
else if ( state == QCheckBox::Off )
{
static_cast<QCheckBox *>( child( "DefaultLoginBox", "QGroupBox", true ) )->setEnabled( false );
}
}
void Smb4KAuthOptions::slotDefaultAuthButtonState( int state )
{
if ( state == QCheckBox::On )
{
static_cast<QCheckBox *>( child( "DefaultAuthWidget", "QWidget", true ) )->setEnabled( true );
}
else if ( state == QCheckBox::Off )
{
static_cast<QCheckBox *>( child( "DefaultAuthWidget", "QWidget", true ) )->setEnabled( false );
}
}
#include "smb4kauthoptions.moc"

@ -0,0 +1,81 @@
/***************************************************************************
smb4kauthoptions - The configuration page for the authentication
settings of Smb4K
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KAUTHOPTIONS_H
#define SMB4KAUTHOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qwidget.h>
/**
* This is the configuration tab for the authentication settings
* of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KAuthOptions : public QWidget
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget
*
* @param name The name of this widget
*/
Smb4KAuthOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KAuthOptions();
protected slots:
/**
* This slot manages the toggling of the KWallet support button in the
* Authentication tab.
*
* @param state The toggle state
*/
void slotKWalletButtonState( int state );
/**
* This slot manages the toggling of the default authentication button.
*
* @param state The toggle state
*/
void slotDefaultAuthButtonState( int state );
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,208 @@
/***************************************************************************
smb4kconfigdialog - The configuration dialog of Smb4K
-------------------
begin : Sa Apr 14 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KCONFIGDIALOG_H
#define SMB4KCONFIGDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kconfigdialog.h>
#include <klibloader.h>
#include <kaboutdata.h>
#include <kinstance.h>
// forward declarations
class Smb4KSettings;
/**
* This is the (new) configuration dialog of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KConfigDialog : public KConfigDialog
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param settings The Smb4KSettings object that needs to be passed
* so that the settings can be managed.
*
* @param parent The parent widget
*
* @param name The name of this dialog
*/
Smb4KConfigDialog( Smb4KSettings *settings, QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KConfigDialog();
protected:
/**
* Reimplemented from QWidget to do last things before the
* configuration dialog is shown.
*
* @param e The show event object
*/
void showEvent( QShowEvent *e );
protected slots:
/**
* Reimplemented from KConfigDialog. This slot does application
* specific stuff first and then executes KConfigDialog::slotApply().
*/
void slotApply();
/**
* Reimplemented from KConfigDialog. This slot does application
* specific stuff first and then executes KConfigDialog::slotOk().
*/
void slotOk();
/**
*Reimplemented from KConfigDialog. This slot does application
* specific stuff first and then executes KConfigDialog::slotCancel().
*/
void slotCancel();
/**
* The custom Samba settings changed. Decide if we have to
* enable the 'Apply' button or not.
*/
void slotCustomSambaSettingsChanged();
/**
* The 'Remove Entries' button in the 'Super User' page has been
* clicked. Initialize the removal of Smb4K's configuration entries
* from the configuration file of the currently chosen program.
*/
void slotRemoveSuperUserEntries();
/**
* This slot is activated if the Smb4KFileIO::failed() signal is
* received. It deselects all check boxes in the "Super User" page.
*/
void slotReceivedFileIOFailed();
/**
* This slot is activated if the Smb4KFileIO::finished() signal is
* received. It closes the dialog by invoking KConfigDialog::slotOk().
*/
void slotReceivedFileIOFinished();
private:
/**
* Load the custom Samba options
*/
void loadCustomSambaOptions();
/**
* Save the custom Samba options
*/
void saveCustomSambaOptions();
/**
* Load the authentication data
*/
void loadAuthenticationData();
/**
* Save the authentication data
*/
void saveAuthenticationData();
/**
* Write super user configuration entries to configuration file.
*
* @returns TRUE if something needs to be written.
*/
bool writeSuperUserEntries();
/**
* Remove super user configuration entries from the configuration file.
*/
void removeSuperUserEntries();
/**
* Checks that mandatorily needed input is provided for settings that
* need it. This function will report all missing input to the user
* via a message box.
*
* @returns TRUE if the check passed and FALSE if it failed.
*/
bool checkSettings();
};
class KInstance;
class KAboutData;
class Smb4KConfigDialogFactory : KLibFactory
{
Q_OBJECT
public:
/**
* The constructor.
*/
Smb4KConfigDialogFactory();
/**
* The destructor.
*/
virtual ~Smb4KConfigDialogFactory();
/**
* The instance
*/
static KInstance *instance();
protected:
QObject *createObject( QObject *parent = 0, const char *name = 0,
const char *classname = "QObject",
const QStringList &args = QStringList() );
private:
/**
* The factory's instance
*/
static KInstance *m_instance;
/**
* The factory's KAboutData object
*/
static KAboutData *m_about;
};
#endif

@ -0,0 +1,107 @@
/***************************************************************************
smb4knetworkoptions - The configuration page for the network
settings of Smb4K
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qbuttongroup.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qlabel.h>
// KDE includes
#include <klocale.h>
#include <klineedit.h>
#include <kcombobox.h>
// application specific includes
#include "smb4knetworkoptions.h"
#include "../core/smb4ksettings.h"
Smb4KNetworkOptions::Smb4KNetworkOptions( QWidget *parent, const char *name ) : QWidget( parent, name )
{
QGridLayout *grid = new QGridLayout( this );
grid->setSpacing( 10 );
//
// The browse list group box.
//
QButtonGroup *browse_box = new QButtonGroup( 1, Qt::Horizontal, i18n( "Browse List" ),
this, "kcfg_BrowseList" );
browse_box->insert( new QRadioButton( i18n( "Scan the network neighborhood for available workgroups and domains" ),
browse_box ), Smb4KSettings::EnumBrowseList::LookupDomains );
browse_box->insert( new QRadioButton( i18n( "Query the current workgroup master browser" ),
browse_box), Smb4KSettings::EnumBrowseList::QueryCurrentMaster );
QWidget *buttonWidget = new QWidget( browse_box );
QGridLayout *buttonLayout = new QGridLayout( buttonWidget );
buttonLayout->setSpacing( 5 );
QRadioButton *use_host = new QRadioButton( i18n( "Query this master browser:" ),
buttonWidget, "CustomMasterBrowserLabel" );
KLineEdit *host_name = new KLineEdit( buttonWidget, "kcfg_CustomMasterBrowser" );
QRadioButton *use_scan = new QRadioButton( i18n( "Scan broadcast areas:" ),
buttonWidget, "BroadcastAreasLabel" );
KLineEdit *broadcast_addresses = new KLineEdit( buttonWidget, "kcfg_BroadcastAreas" );
buttonLayout->addWidget( use_host, 0, 0, 0 );
buttonLayout->addWidget( host_name, 0, 1, 0 );
buttonLayout->addWidget( use_scan, 1, 0, 0 );
buttonLayout->addWidget( broadcast_addresses, 1, 1, 0 );
browse_box->insert( use_host, Smb4KSettings::EnumBrowseList::QueryCustomMaster );
browse_box->insert( use_scan, Smb4KSettings::EnumBrowseList::ScanBroadcastAreas );
//
// The search group box
//
QButtonGroup *search_box = new QButtonGroup( 1, Qt::Horizontal, i18n( "Network Search" ),
this, "kcfg_SearchMethod" );
search_box->setInsideSpacing( 5 );
QLabel *description = new QLabel( search_box );
description->setText( i18n( "Smb4K uses \"nmblookup\" by default to search for remote hosts. This method is very reliable but fails sometimes if your network neighborhood is configured uncommonly. In this case you should try to use \"smbclient\"." ) );
description->setTextFormat( Qt::RichText );
search_box->insert( new QRadioButton( i18n( "Use nmblookup (recommended)" ),
search_box ), Smb4KSettings::EnumSearchMethod::Nmblookup );
search_box->insert( new QRadioButton( i18n( "Use smbclient" ),
search_box ), Smb4KSettings::EnumSearchMethod::Smbclient );
QSpacerItem *spacer4 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
grid->addWidget( browse_box, 0, 0, 0 );
grid->addWidget( search_box, 1, 0, 0 );
grid->addItem( spacer4, 2, 0 );
}
Smb4KNetworkOptions::~Smb4KNetworkOptions()
{
}
#include "smb4knetworkoptions.moc"

@ -0,0 +1,63 @@
/***************************************************************************
smb4knetworkoptions - The configuration page for the network
settings of Smb4K
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KNETWORKOPTIONS_H
#define SMB4KNETWORKOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qwidget.h>
/**
* This is the configuration tab for the network settings
* of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KNetworkOptions : public QWidget
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent widget
*
* @param name The widget's name
*/
Smb4KNetworkOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KNetworkOptions();
};
#endif

@ -0,0 +1,351 @@
/***************************************************************************
smb4ksynchronizeoptions - The configuration page for the rsync options
-------------------
begin : So Nov 20 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qradiobutton.h>
// KDE includes
#include <klocale.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <knuminput.h>
#include <klineedit.h>
#include <kfile.h>
// application specific includes
#include "smb4krsyncoptions.h"
Smb4KRsyncOptions::Smb4KRsyncOptions( QWidget *parent, const char *name ) : QTabWidget( parent, name )
{
setMargin( 10 );
//
// The Copying tab
//
QWidget *copying_tab = new QWidget( this, "RsyncCopying" );
QGridLayout *copying_layout = new QGridLayout( copying_tab );
copying_layout->setSpacing( 10 );
QGroupBox *directory_box = new QGroupBox( 2, QGroupBox::Horizontal, i18n( "Default Destination" ),
copying_tab, "RsyncDestinationBox" );
directory_box->setInsideSpacing( 5 );
(void) new QLabel( i18n( "Rsync prefix:" ), directory_box, "RsyncPrefixLabel" );
KURLRequester *prefix = new KURLRequester( directory_box, "kcfg_RsyncPrefix" );
prefix->setMode( KFile::Directory | KFile::LocalOnly );
QButtonGroup *general_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "General" ),
copying_tab, "RsyncModeBox" );
general_box->setInsideSpacing( 5 );
QCheckBox *archive_mode = new QCheckBox( i18n( "Archive mode" ), general_box, "kcfg_ArchiveMode" );
QCheckBox *recursive = new QCheckBox( i18n( "Recurse into directories" ), general_box, "kcfg_RecurseIntoDirectories" );
(void) new QCheckBox( i18n( "Skip files that are newer in target directory" ), general_box, "kcfg_UpdateTarget" );
(void) new QCheckBox( i18n( "Update destination files in place" ), general_box, "kcfg_UpdateInPlace" );
(void) new QCheckBox( i18n( "Use relative path names" ), general_box, "kcfg_RelativePathNames" );
(void) new QCheckBox( i18n( "Don't send implied directories" ), general_box, "kcfg_NoImpliedDirectories" );
(void) new QCheckBox( i18n( "Transfer directories without recursing" ), general_box, "kcfg_TransferDirectories" );
(void) new QCheckBox( i18n( "Compress data during transfer" ), general_box, "kcfg_CompressData" );
QButtonGroup *links_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Links" ), copying_tab, "RsyncModeBox" );
links_box->setInsideSpacing( 5 );
QCheckBox *links = new QCheckBox( i18n( "Preserve symlinks" ), links_box, "kcfg_PreserveSymlinks" );
(void) new QCheckBox( i18n( "Transform symlinks" ), links_box, "kcfg_TransformSymlinks" );
(void) new QCheckBox( i18n( "Only transform unsafe symlinks" ), links_box, "kcfg_TransformUnsafeSymlinks" );
(void) new QCheckBox( i18n( "Ignore unsafe symlinks" ), links_box, "kcfg_IgnoreUnsafeSymlinks" );
(void) new QCheckBox( i18n( "Preserve hard links" ), links_box, "kcfg_PreserveHardLinks" );
(void) new QCheckBox( i18n( "Keep directory symlinks" ), links_box, "kcfg_KeepDirectorySymlinks" );
QButtonGroup *perm_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "File Permissions, etc." ),
copying_tab, "RsyncPreservationBox" );
perm_box->setInsideSpacing( 5 );
QCheckBox *perms = new QCheckBox( i18n( "Preserve permissions" ), perm_box, "kcfg_PreservePermissions" );
QCheckBox *group = new QCheckBox( i18n( "Preserve group" ), perm_box, "kcfg_PreserveGroup" );
QCheckBox *owner = new QCheckBox( i18n( "Preserve owner" ), perm_box, "kcfg_PreserveOwner" );
QCheckBox *devices = new QCheckBox( i18n( "Preserve device and special files" ), perm_box, "kcfg_PreserveDevicesAndSpecials" );
QCheckBox *times = new QCheckBox( i18n( "Preserve times" ), perm_box, "kcfg_PreserveTimes" );
(void) new QCheckBox( i18n( "Omit directories when preserving times" ), perm_box, "kcfg_OmitDirectoryTimes" );
QSpacerItem *spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
copying_layout->addWidget( directory_box, 0, 0, 0 );
copying_layout->addWidget( general_box, 1, 0, 0 );
copying_layout->addWidget( links_box, 2, 0, 0 );
copying_layout->addWidget( perm_box, 3, 0, 0 );
copying_layout->addItem( spacer1, 4, 0 );
addTab( copying_tab, i18n( "Copying" ) );
//
// The File Deletion & Transfer tab
//
QWidget *deltrans_tab = new QWidget( this, "RsyncFileDeletion" );
QGridLayout *deltrans_layout = new QGridLayout( deltrans_tab );
deltrans_layout->setSpacing( 10 );
QButtonGroup *delete_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "File Deletion" ), deltrans_tab, "RsyncDeleteBox" );
delete_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Remove synchronized source files" ), delete_box, "kcfg_RemoveSourceFiles" );
(void) new QCheckBox( i18n( "Delete extraneous files" ), delete_box, "kcfg_DeleteExtraneous" );
(void) new QCheckBox( i18n( "Delete files before transfer" ), delete_box, "kcfg_DeleteBefore" );
(void) new QCheckBox( i18n( "Delete files after transfer" ), delete_box, "kcfg_DeleteAfter" );
(void) new QCheckBox( i18n( "Delete files during transfer" ), delete_box, "kcfg_DeleteDuring" );
(void) new QCheckBox( i18n( "Also delete excluded files" ), delete_box, "kcfg_DeleteExcluded" );
(void) new QCheckBox( i18n( "Delete even if I/O errors occur" ), delete_box, "kcfg_IgnoreErrors" );
(void) new QCheckBox( i18n( "Force deletion of non-void directories" ), delete_box, "kcfg_ForceDirectoryDeletion" );
QButtonGroup *delete_restrictions_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Restrictions" ), deltrans_tab, "RsyncDeleteRestrictionsBox" );
delete_restrictions_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Don't delete more than this many files:" ), delete_restrictions_box, "kcfg_UseMaximumDelete" );
(void) new KIntNumInput( delete_restrictions_box, "kcfg_MaximumDeleteValue" );
QButtonGroup *transfer_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "File Transfer" ),
deltrans_tab, "RsyncFileTransferBox" );
transfer_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Don't transfer any file smaller than:" ), transfer_box, "kcfg_UseMinimalTransferSize" );
KIntNumInput *min_size = new KIntNumInput( transfer_box, "kcfg_MinimalTransferSize" );
min_size->setSuffix( " kB" );
(void) new QCheckBox( i18n( "Don't transfer any file larger than:" ), transfer_box, "kcfg_UseMaximalTransferSize" );
KIntNumInput *max_size = new KIntNumInput( transfer_box, "kcfg_MaximalTransferSize" );
max_size->setSuffix( " kB" );
(void) new QCheckBox( i18n( "Keep partially transferred files" ), transfer_box, "kcfg_KeepPartial" );
transfer_box->addSpace( 0 );
(void) new QCheckBox( i18n( "Put a partially transferred file into:" ), transfer_box, "kcfg_UsePartialDirectory" );
KURLRequester *partial_dir = new KURLRequester( transfer_box, "kcfg_PartialDirectory" );
partial_dir->setMode( KFile::Directory | KFile::LocalOnly );
QSpacerItem *spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
deltrans_layout->addWidget( delete_box, 0, 0, 0 );
deltrans_layout->addWidget( delete_restrictions_box, 1, 0, 0 );
deltrans_layout->addWidget( transfer_box, 2, 0, 0 );
deltrans_layout->addItem( spacer2, 3, 0 );
addTab( deltrans_tab, i18n( "File Deletion && Transfer" ) );
//
// The Filter tab
//
QWidget *filter_tab = new QWidget( this, "RsyncFiltering" );
QGridLayout *filter_layout = new QGridLayout( filter_tab );
filter_layout->setSpacing( 10 );
QButtonGroup *general_filter_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "General" ),
filter_tab, "RsyncGeneralFilterBox" );
general_filter_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Auto-ignore files in the same way CVS does" ), general_filter_box, "kcfg_UseCVSExclude" );
general_filter_box->addSpace( 0 );
(void) new QCheckBox( i18n( "Exclude files matching this pattern:" ), general_filter_box, "kcfg_UseExcludePattern" );
(void) new KLineEdit( general_filter_box, "kcfg_ExcludePattern" );
(void) new QCheckBox( i18n( "Read exclude patterns from:" ), general_filter_box, "kcfg_UseExcludeFrom" );
KURLRequester *exclude_from = new KURLRequester( general_filter_box, "kcfg_ExcludeFrom" );
exclude_from->setMode( KFile::File | KFile::LocalOnly );
(void) new QCheckBox( i18n( "Don't exclude files matching this pattern:" ), general_filter_box, "kcfg_UseIncludePattern" );
(void) new KLineEdit( general_filter_box, "kcfg_IncludePattern" );
(void) new QCheckBox( i18n( "Read include patterns from:" ), general_filter_box, "kcfg_UseIncludeFrom" );
KURLRequester *include_from = new KURLRequester( general_filter_box, "kcfg_IncludeFrom" );
include_from->setMode( KFile::File | KFile::LocalOnly );
QButtonGroup *filter_rules_box = new QButtonGroup( 1, QGroupBox::Horizontal, i18n( "Filter Rules" ),
filter_tab, "RsyncFilterRulesBox" );
filter_rules_box->setInsideSpacing( 5 );
QLabel *filter_rules_label = new QLabel( i18n( "The rules defined below will be added to the \"rsync\" command as they are. Thus, you have to start with the --filter=... argument." ), filter_rules_box );
filter_rules_label->setTextFormat( Qt::RichText );
(void) new KLineEdit( filter_rules_box, "kcfg_CustomFilteringRules" );
(void) new QLabel( i18n( "Special filter rules:" ), filter_rules_box );
QCheckBox *f_filter = new QCheckBox( i18n( "Use --filter='dir-merge /.rsync-filter' filter rule" ), filter_rules_box, "kcfg_UseFFilterRule" );
QCheckBox *ff_filter = new QCheckBox( i18n( "Use --filter='exclude .rsync-filter' filter rule" ), filter_rules_box, "kcfg_UseFFFilterRule" );
QSpacerItem *spacer3 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
filter_layout->addWidget( general_filter_box, 0, 0, 0 );
filter_layout->addWidget( filter_rules_box, 1, 0, 0 );
filter_layout->addItem( spacer3, 2, 0 );
addTab( filter_tab, i18n( "Filtering" ) );
//
// The Advanced tab
//
QWidget *advanced_tab = new QWidget( this, "RsyncAdvanced" );
QGridLayout *advanced_layout = new QGridLayout( advanced_tab );
advanced_layout->setSpacing( 10 );
QButtonGroup *misc_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "General" ),
advanced_tab, "RsyncAdvancedMiscBox" );
misc_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Handle sparse files efficiently" ), misc_box, "kcfg_EfficientSparseFileHandling" );
(void) new QCheckBox( i18n( "Copy files whole (no rsync algorithm)" ), misc_box, "kcfg_CopyFilesWhole" );
(void) new QCheckBox( i18n( "Don't cross file system boundaries" ), misc_box, "kcfg_OneFileSystem" );
(void) new QCheckBox( i18n( "Only update files that already exist" ), misc_box, "kcfg_UpdateExisting" );
(void) new QCheckBox( i18n( "Ignore files that already exist" ), misc_box, "kcfg_IgnoreExisting" );
(void) new QCheckBox( i18n( "Delay updates until the end of transfer" ), misc_box, "kcfg_DelayUpdates" );
QButtonGroup *backup_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Backup" ), advanced_tab, "RsyncBackupBox" );
backup_box->setInsideSpacing( 5 );
QCheckBox *backup = new QCheckBox( i18n( "Make backups" ), backup_box, "kcfg_MakeBackups" );
backup_box->addSpace( 0 );
(void) new QCheckBox( i18n( "Backup suffix:" ), backup_box, "kcfg_UseBackupSuffix" );
(void) new KLineEdit( backup_box, "kcfg_BackupSuffix" );
(void) new QCheckBox( i18n( "Backup directory:" ), backup_box, "kcfg_UseBackupDirectory" );
KURLRequester *backup_dir = new KURLRequester( backup_box, "kcfg_BackupDirectory" );
backup_dir->setMode( KFile::Directory | KFile::LocalOnly );
QButtonGroup *checksum_box = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Checksums" ), advanced_tab, "RsyncChecksumsBox" );
checksum_box->setInsideSpacing( 5 );
(void) new QCheckBox( i18n( "Force fixed checksum block size:" ), checksum_box, "kcfg_UseBlockSize" );
(void) new KIntNumInput( checksum_box, "kcfg_BlockSize" );
(void) new QCheckBox( i18n( "Set block/file checksum seed:" ), checksum_box, "kcfg_UseChecksumSeed" );
(void) new KIntNumInput( checksum_box, "kcfg_ChecksumSeed" );
(void) new QCheckBox( i18n( "Skip files based on checksum" ), checksum_box, "kcfg_UseChecksum" );
checksum_box->addSpace( 0 );
QSpacerItem *spacer4 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
advanced_layout->addWidget( misc_box, 0, 0, 0 );
advanced_layout->addWidget( backup_box, 1, 0, 0 );
advanced_layout->addWidget( checksum_box, 2, 0, 0 );
advanced_layout->addItem( spacer4, 3, 0 );
addTab( advanced_tab, i18n( "Advanced" ) );
connect( archive_mode, SIGNAL( toggled( bool ) ),
this, SLOT( slotArchiveToggled( bool ) ) );
connect( recursive, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( links, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( perms, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( times, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( group, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( owner, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( devices, SIGNAL( toggled( bool ) ),
this, SLOT( slotUncheckArchive( bool ) ) );
connect( backup, SIGNAL( toggled( bool ) ),
this, SLOT( slotBackupToggled( bool ) ) );
connect( f_filter, SIGNAL( toggled( bool ) ),
this, SLOT( slotFShortcutToggled( bool ) ) );
connect( ff_filter, SIGNAL( toggled( bool ) ),
this, SLOT( slotFFShortcutToggled( bool ) ) );
slotArchiveToggled( true );
slotBackupToggled( false );
}
Smb4KRsyncOptions::~Smb4KRsyncOptions()
{
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KRsyncOptions::slotArchiveToggled( bool on )
{
if ( on )
{
static_cast<QCheckBox *>( child( "kcfg_RecurseIntoDirectories", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreserveSymlinks", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreservePermissions", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreserveTimes", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreserveGroup", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreserveOwner", "QCheckBox", true ) )->setChecked( on );
static_cast<QCheckBox *>( child( "kcfg_PreserveDevicesAndSpecials", "QCheckBox", true ) )->setChecked( on );
}
}
void Smb4KRsyncOptions::slotUncheckArchive( bool on )
{
if ( !on )
{
static_cast<QCheckBox *>( child( "kcfg_ArchiveMode", "QCheckBox", true ) )->setChecked( on );
}
}
void Smb4KRsyncOptions::slotBackupToggled( bool on )
{
static_cast<QCheckBox *>( child( "kcfg_UseBackupDirectory", "QCheckBox", true ) )->setEnabled( on );
static_cast<KURLRequester *>( child( "kcfg_BackupDirectory", "KURLRequester", true ) )->setEnabled( on );
static_cast<QCheckBox *>( child( "kcfg_UseBackupSuffix", "QCheckBox", true ) )->setEnabled( on );
static_cast<KLineEdit *>( child( "kcfg_BackupSuffix", "KLineEdit", true ) )->setEnabled( on );
}
void Smb4KRsyncOptions::slotFShortcutToggled( bool on )
{
QCheckBox *ff_filter = static_cast<QCheckBox *>( child( "kcfg_UseFFFilterRule", "QCheckBox", true ) );
if ( on && ff_filter->isChecked() )
{
ff_filter->setChecked( false );
}
}
void Smb4KRsyncOptions::slotFFShortcutToggled( bool on )
{
QCheckBox *f_filter = static_cast<QCheckBox *>( child( "kcfg_UseFFilterRule", "QCheckBox", true ) );
if ( on && f_filter->isChecked() )
{
f_filter->setChecked( false );
}
}
#include "smb4krsyncoptions.moc"

@ -0,0 +1,108 @@
/***************************************************************************
smb4krsyncoptions - The configuration page for the rsync options
-------------------
begin : So Nov 20 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KRSYNCOPTIONS_H
#define SMB4KRSYNCOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qtabwidget.h>
/**
* This class belongs to the configuration dialog and takes
* care of the options that can be defined for rsync.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KRsyncOptions : public QTabWidget
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget
*
* @param name The name of this widget
*/
Smb4KRsyncOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KRsyncOptions();
protected slots:
/**
* This slot is invoked if the "Archive mode" checkbox has been
* toggled.
*
* @param on Is TRUE if the checkbox is checked and FALSE otherwise.
*/
void slotArchiveToggled( bool on );
/**
* This slot is invoked if the --archive option has to be switched
* off.
*
* @param on Is FALSE if one of the connected checkboxes is unchecked
* and TRUE otherwise.
*/
void slotUncheckArchive( bool on );
/**
* This slot is called, when the backup checkbox has been toggled.
* It enables/disables all other backup options according to the
* state the backup button is in.
*
* @param on Is TRUE if the m_backup check box has been
* checked and FALSE otherwise.
*/
void slotBackupToggled( bool on );
/**
* This slot is called if the '-F' shortcut has been toggled.
* It unchecks the '-F -F' shortcut.
*
* @param on Is TRUE is m_f_filter is checked and FALSE otherwise.
*/
void slotFShortcutToggled( bool on );
/**
* This slot is called if the '-F -F' shortcut has been toggled.
* It unchecks the '-F' shortcut.
*
* @param on Is TRUE is m_ff_filter is checked and FALSE otherwise.
*/
void slotFFShortcutToggled( bool on );
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,168 @@
/***************************************************************************
smb4ksambaoptions.cpp - This is the configuration page for the
Samba settings of Smb4K
-------------------
begin : Mo Jan 26 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSAMBAOPTIONS_H
#define SMB4KSAMBAOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qtabwidget.h>
/**
* This class manages the configuration dialog of the options
* that can be passed to smbmount and other programs of the
* Samba software suite.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSambaOptions : public QTabWidget
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget
*
* @param name This widget's name
*/
Smb4KSambaOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KSambaOptions();
/**
* This enumeration is used for the list view in the "Custom" tab.
*/
#ifndef __FreeBSD__
enum Columns{ ItemName = 0, Protocol = 1, FileSystem = 2, WriteAccess = 3, Kerberos = 4, UID = 5, GID = 6, Port = 7 };
#else
enum Columns{ ItemName = 0, Protocol = 1, Kerberos = 2, UID = 3, GID = 4, Port = 5 };
#endif
/**
* Reset the 'Custom' options tab.
*/
void resetCustomTab();
signals:
/**
* This signal is emitted everytime the custom settings were changed by the
* user. That may mean, that only one setting has has been altered but also
* that all custom entries have been deleted. You have to figure out what
* happened in the slot that's connected to this signal.
*/
void customSettingsChanged();
protected slots:
/**
* Enables/disables widgets according to the choice of the filesystem (SMBFS/CIFS).
*
* This slot is connected to the combo box that stores the file systems.
*
* @param item_index The index of the item in the combo box.
*/
void slotSambaFileSystem( int item_index );
/**
* This slot is invoked if an item in the list of custom options has been
* clicked. It will put the values that are carried by the list view item
* into the editor combo boxes, num inputs, etc.
*
* @param item The item that has been clicked/highlighted.
*/
void slotCustomItemClicked( QListViewItem *item );
/**
* Commit the new custom protocol to the list view item.
*
* @param index The index number of the new protocol
*/
void slotCustomProtocolChanged( int index );
/**
* Commit the new custom file system to the list view item.
*
* @param index The index number of the new file system
*/
void slotCustomFileSystemChanged( int index );
/**
* Commit the new custom write access setting to the list view item.
*
* @param index The index number of the new setting
*/
void slotCustomWriteAccessChanged( int index );
/**
* Commit the new custom Kerberos setting to the list view item.
*
* @param index The index number of the new setting
*/
void slotCustomKerberosChanged( int index );
/**
* Commit the new custom UID to the list view item.
*
* @param uid The new UID in text form
*/
void slotCustomUIDChanged( const QString &uid );
/**
* This slot is invoked if the value for the custom GID setting changed.
*
* @param gid The new GID in text form
*/
void slotCustomGIDChanged( const QString &gid );
/**
* Commit the new custom port number to the list view item.
*
* @param port The port number
*/
void slotCustomPortChanged( int port );
/**
* Remove the highlighted item from the custom options list.
*/
void slotRemoveCustomOption();
/**
* Remove all items from the custom options list.
*/
void slotRemoveAllCustomOptions();
};
#endif

@ -0,0 +1,98 @@
/***************************************************************************
smb4kshareoptions - The configuration page for the settings of
Smb4K regarding share management
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qgroupbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qcheckbox.h>
// KDE includes
#include <klocale.h>
#include <kbuttonbox.h>
#include <kurlrequester.h>
#include <knuminput.h>
// system includes
#include <sys/types.h>
#include <pwd.h>
// applications specific includes
#include "smb4kshareoptions.h"
Smb4KShareOptions::Smb4KShareOptions( QWidget *parent, const char *name ) : QWidget( parent, name )
{
QGridLayout *grid = new QGridLayout( this );
grid->setSpacing( 10 );
QGroupBox *dir_box = new QGroupBox( 1, Qt::Horizontal, i18n( "Directories" ), this );
QWidget *prefix_container = new QWidget( dir_box );
QGridLayout *prefix_layout = new QGridLayout( prefix_container );
prefix_layout->setSpacing( 10 );
QLabel *prefix = new QLabel( i18n( "Mount prefix:" ), prefix_container );
KURLRequester *mount_prefix = new KURLRequester( QString::null, prefix_container,
"kcfg_MountPrefix" );
mount_prefix->setMode( KFile::Directory );
prefix_layout->addWidget( prefix, 0, 0, 0 );
prefix_layout->addWidget( mount_prefix, 0, 1, 0 );
(void) new QCheckBox( i18n( "Force generated subdirectories to be lower case" ),
dir_box, "kcfg_ForceLowerCaseSubdirs" );
QButtonGroup *mount_box = new QButtonGroup( 1, QButtonGroup::Horizontal, i18n( "Mounting and Unmounting" ), this );
(void) new QCheckBox( i18n( "Unmount all shares of user %1 on exit" ).arg( getpwuid( getuid() )->pw_name ),
mount_box, "kcfg_UnmountSharesOnExit" );
(void) new QCheckBox( i18n( "Remount recently used shares on program start" ),
mount_box, "kcfg_RemountShares" );
(void) new QCheckBox( i18n( "Allow the unmounting of shares that are owned by other users" ),
mount_box, "kcfg_UnmountForeignShares" );
QGroupBox *checks_box = new QGroupBox( 2, QGroupBox::Horizontal, i18n( "Checks" ), this );
(void) new QLabel( i18n( "Interval between checks:" ), checks_box );
KIntNumInput *check_interval = new KIntNumInput( 2500, checks_box, 10,
"kcfg_CheckInterval" );
check_interval->setSuffix( " ms" );
check_interval->setRange( 500, 300000, 1, false );
QSpacerItem *spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
grid->addWidget( dir_box, 0, 0, 0 );
grid->addWidget( mount_box, 1, 0, 0 );
grid->addWidget( checks_box, 2, 0, 0 );
grid->addItem( spacer2, 3, 0 );
}
Smb4KShareOptions::~Smb4KShareOptions()
{
}
#include "smb4kshareoptions.moc"

@ -0,0 +1,62 @@
/***************************************************************************
smb4kshareoptions - The configuration page for the settings of
Smb4K regarding share management
-------------------
begin : Sa Nov 15 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHAREOPTIONS_H
#define SMB4KSHAREOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qwidget.h>
/**
* This is the configuration tab for the settings that are
* used to manage the mounted shares.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KShareOptions : public QWidget
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent of this widget
*
* @param name The name of this widget
*/
Smb4KShareOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KShareOptions();
};
#endif

@ -0,0 +1,101 @@
/***************************************************************************
smb4ksuperuseroptions - The configuration page for the super user
settings of Smb4K
-------------------
begin : Sa Okt 30 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qgroupbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
// KDE includes
#include <klocale.h>
#include <kpushbutton.h>
#include <kguiitem.h>
// application specific includes
#include "smb4ksuperuseroptions.h"
#include "../core/smb4ksettings.h"
Smb4KSuperUserOptions::Smb4KSuperUserOptions( QWidget *parent, const char *name )
: QWidget( parent, name )
{
QGridLayout *grid = new QGridLayout( this );
grid->setSpacing( 10 );
QButtonGroup *suid_progs = new QButtonGroup( 1, QButtonGroup::Horizontal,
i18n( "Programs" ), this, "kcfg_SuperUserProgram" );
suid_progs->setInsideSpacing( 5 );
new QLabel( i18n( "Use the following program to gain super user privileges:" ), suid_progs );
suid_progs->insert( new QRadioButton( "sudo", suid_progs, "SudoButton" ), Smb4KSettings::EnumSuperUserProgram::Sudo );
suid_progs->insert( new QRadioButton( "super", suid_progs, "SuperButton" ), Smb4KSettings::EnumSuperUserProgram::Super );
QButtonGroup *suid_actions = new QButtonGroup( 1, QButtonGroup::Horizontal, i18n( "Actions" ), this, "SUIDActions" );
suid_actions->setInsideSpacing( 5 );
#ifdef __linux__
(void) new QCheckBox( i18n( "Use super user privileges to force the unmounting of (inaccessible) shares" ), suid_actions, "kcfg_UseForceUnmount" );
#endif
(void) new QCheckBox( i18n( "Use super user privileges to mount and unmount shares" ), suid_actions, "kcfg_AlwaysUseSuperUser" );
QSpacerItem *spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred );
KGuiItem remove_item = KGuiItem( i18n( "Remove Entries" ), "editdelete",
i18n( "Remove entries from the configuration file" ),
i18n( "Depending on your choice under \"Programs\", all entries that were written by Smb4K will be removed either from /etc/super.tab or /etc/sudoers. Additionally, all your choices under \"Actions\" will be cleared." ) );
KPushButton *remove = new KPushButton( remove_item, this, "RemoveButton" );
QSpacerItem *spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
grid->addMultiCellWidget( suid_progs, 0, 0, 0, 3, 0 );
grid->addMultiCellWidget( suid_actions, 1, 1, 0, 3, 0 );
grid->addMultiCell( spacer1, 2, 2, 0, 2, 0 );
grid->addWidget( remove, 2, 3, 0 );
grid->addMultiCell( spacer2, 3, 3, 0, 3, 0 );
connect( remove, SIGNAL( clicked() ),
this, SLOT( slotRemoveClicked() ) );
}
Smb4KSuperUserOptions::~Smb4KSuperUserOptions()
{
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSuperUserOptions::slotRemoveClicked()
{
// Emit the signal that the removal of the super user
// entries has been requested.
emit removeEntries();
}
#include "smb4ksuperuseroptions.moc"

@ -0,0 +1,79 @@
/***************************************************************************
smb4ksuperuseroptions - The configuration page for the super user
settings of Smb4K
-------------------
begin : Sa Okt 30 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSUPERUSEROPTIONS_H
#define SMB4KSUPERUSEROPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qwidget.h>
/**
* This is the configuration tab where the user can determine
* whether he/she wants to use the program super or sudo to
* gain super user privileges.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSuperUserOptions : public QWidget
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent widget
*
* @param name The name of this widget
*/
Smb4KSuperUserOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KSuperUserOptions();
signals:
/**
* This signal is emitted when the "Remove Entries" button has been
* clicked. It is provided for convenience. You could also connect
* to the clicked() signal.
*/
void removeEntries();
protected slots:
/**
* This slot is activated when the "Remove Entries" button has been
* clicked.
*/
void slotRemoveClicked();
};
#endif

@ -0,0 +1,207 @@
/***************************************************************************
smb4kuserinterfaceoptions - This configuration page takes care
of all settings concerning the user interface of Smb4K
-------------------
begin : Mi Aug 30 2006
copyright : (C) 2006-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
// KDE includes
#include <klocale.h>
// application specific includes
#include "smb4kuserinterfaceoptions.h"
#include "../core/smb4ksettings.h"
Smb4KUserInterfaceOptions::Smb4KUserInterfaceOptions( QWidget *parent, const char *name )
: QTabWidget( parent, name )
{
setMargin( 10 );
//
// Configuration for the main window:
//
QWidget *main_wd_widget = new QWidget( this );
QGridLayout *main_wd_layout = new QGridLayout( main_wd_widget );
main_wd_layout->setSpacing( 10 );
QButtonGroup *shares_view = new QButtonGroup( 1, Qt::Horizontal, i18n( "Shares View" ),
main_wd_widget, "kcfg_SharesView" );
shares_view->insert( new QRadioButton( i18n( "Show mounted shares in an icon view" ), shares_view ), Smb4KSettings::EnumSharesView::IconView );
shares_view->insert( new QRadioButton( i18n( "Show mounted shares in a list view" ), shares_view ), Smb4KSettings::EnumSharesView::ListView );
QButtonGroup *bookmarks_grp = new QButtonGroup( 1, Qt::Horizontal, i18n( "Bookmarks" ),
main_wd_widget, "BookmarksBox" );
(void) new QCheckBox( i18n( "Show custom bookmark label if available" ), bookmarks_grp, "kcfg_ShowCustomBookmarkLabel" );
QButtonGroup *tray_group = new QButtonGroup( 1, Qt::Horizontal, i18n( "System Tray" ),
main_wd_widget, "SystemTrayBox" );
(void) new QCheckBox( i18n( "Embed application into the system tray" ), tray_group, "kcfg_EmbedIntoSystemTray" );
QSpacerItem *spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
main_wd_layout->addWidget( shares_view, 0, 0, 0 );
main_wd_layout->addWidget( bookmarks_grp, 1, 0, 0 );
main_wd_layout->addWidget( tray_group, 2, 0, 0 );
main_wd_layout->addItem( spacer1, 3, 0 );
//
// Configuration for the network browser:
//
QWidget *browser_widget = new QWidget( this );
QGridLayout *browser_layout = new QGridLayout( browser_widget );
browser_layout->setSpacing( 10 );
QButtonGroup *remoteGroup = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Remote Shares" ),
browser_widget, "BrowserRemoteSharesBox" );
(void) new QCheckBox( i18n( "Show printer shares" ), remoteGroup, "kcfg_ShowPrinterShares" );
QCheckBox *hidden = new QCheckBox( i18n( "Show hidden shares" ), remoteGroup, "kcfg_ShowHiddenShares" );
(void) new QCheckBox( i18n( "Show IPC$ shares" ), remoteGroup, "kcfg_ShowHiddenIPCShares" );
(void) new QCheckBox( i18n( "Show ADMIN$ shares" ), remoteGroup, "kcfg_ShowHiddenADMINShares" );
QButtonGroup *columnsGroup = new QButtonGroup( 2, QButtonGroup::Horizontal, i18n( "Columns" ),
browser_widget, "BrowserColumnsBox" );
(void) new QCheckBox( i18n( "Show type" ), columnsGroup, "kcfg_ShowType" );
(void) new QCheckBox( i18n( "Show IP address" ), columnsGroup, "kcfg_ShowIPAddress" );
(void) new QCheckBox( i18n( "Show comment" ), columnsGroup, "kcfg_ShowComment" );
QButtonGroup *netTooltipsGroup = new QButtonGroup( 1, QButtonGroup::Horizontal, i18n( "Tooltips" ),
browser_widget, "BrowserTooltipsBox" );
(void) new QCheckBox( i18n( "Show tooltip with information about a network item" ), netTooltipsGroup, "kcfg_ShowNetworkItemToolTip" );
QSpacerItem *spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
browser_layout->addWidget( remoteGroup, 0, 0, 0 );
browser_layout->addWidget( columnsGroup, 1, 0, 0 );
browser_layout->addWidget( netTooltipsGroup, 2, 0, 0 );
browser_layout->addItem( spacer2, 3, 0 );
//
// Configuration for the shares view
//
QWidget *shares_widget = new QWidget( this );
QGridLayout *shares_layout = new QGridLayout( shares_widget );
shares_layout->setSpacing( 10 );
QButtonGroup *shares_group = new QButtonGroup( 1, Qt::Horizontal, i18n( "Mounted Shares" ),
shares_widget, "SharesIconGroupBox" );
(void) new QCheckBox( i18n( "Show mount point instead of share name" ), shares_group, "kcfg_ShowMountPoint" );
(void) new QCheckBox( i18n( "Show all shares that are mounted on the system" ), shares_group, "kcfg_ShowAllShares" );
QButtonGroup *dnd_group = new QButtonGroup( 1, Qt::Horizontal, i18n( "Drag and Drop" ),
shares_widget, "DragnDropBox" );
(void) new QCheckBox( i18n( "Allow dropping of files and directories onto shares" ), dnd_group, "kcfg_EnableDropSupport" );
(void) new QCheckBox( i18n( "Allow dragging of shares" ), dnd_group, "kcfg_EnableDragSupport" );
QButtonGroup *sharesTooltipGroup = new QButtonGroup( 1, Qt::Horizontal, i18n( "Tooltips" ),
shares_widget, "SharesTooltipsBox" );
(void) new QCheckBox( i18n( "Show tooltip with information about a share" ), sharesTooltipGroup, "kcfg_ShowShareToolTip" );
QButtonGroup *list_view_group = new QButtonGroup( 2, Qt::Horizontal, i18n( "List View" ),
shares_widget, "SharesListViewBox" );
#ifndef __FreeBSD__
(void) new QCheckBox( i18n( "Show owner and group (SMBFS only)" ), list_view_group, "kcfg_ShowOwner" );
(void) new QCheckBox( i18n( "Show login (CIFS only)" ), list_view_group, "kcfg_ShowLogin" );
#else
(void) new QCheckBox( i18n( "Show owner and group" ), list_view_group, "kcfg_ShowOwner" );
#endif
(void) new QCheckBox( i18n( "Show file system" ), list_view_group, "kcfg_ShowFileSystem" );
(void) new QCheckBox( i18n( "Show free disk space" ), list_view_group, "kcfg_ShowFreeDiskSpace" );
(void) new QCheckBox( i18n( "Show used disk space" ), list_view_group, "kcfg_ShowUsedDiskSpace" );
(void) new QCheckBox( i18n( "Show total disk space" ), list_view_group, "kcfg_ShowTotalDiskSpace" );
(void) new QCheckBox( i18n( "Show disk usage" ), list_view_group, "kcfg_ShowDiskUsage" );
QSpacerItem *spacer3 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
shares_layout->addWidget( shares_group, 0, 0, 0 );
shares_layout->addWidget( dnd_group, 1, 0, 0 );
shares_layout->addWidget( sharesTooltipGroup, 2, 0, 0 );
shares_layout->addWidget( list_view_group, 3, 0, 0 );
shares_layout->addItem( spacer3, 4, 0 );
//
// Configuration for the preview dialog
//
QWidget *preview_widget = new QWidget( this );
QGridLayout *preview_layout = new QGridLayout( preview_widget );
preview_layout->setSpacing( 10 );
QButtonGroup *previewFilesGroup = new QButtonGroup( 1, QButtonGroup::Horizontal, i18n( "Hidden Files and Directories" ), preview_widget, "HiddenFilesBox" );
(void) new QCheckBox( i18n( "Preview hidden files and directories" ), previewFilesGroup, "kcfg_PreviewHiddenItems" );
QSpacerItem *spacer4 = new QSpacerItem( 0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding );
preview_layout->addWidget( previewFilesGroup, 0, 0, 0 );
preview_layout->addItem( spacer4, 1, 0 );
//
// Add tabs:
//
addTab( main_wd_widget, i18n( "Main Window && System Tray" ) );
addTab( browser_widget, i18n( "Network Browser" ) );
addTab( shares_widget, i18n( "Shares View" ) );
addTab( preview_widget, i18n( "Preview Dialog" ) );
// Add connections:
connect( hidden, SIGNAL( stateChanged( int ) ),
this, SLOT( slotShowHiddenShares( int ) ) );
// Do last adjustments:
slotShowHiddenShares( hidden->state() );
}
Smb4KUserInterfaceOptions::~Smb4KUserInterfaceOptions()
{
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KUserInterfaceOptions::slotShowHiddenShares( int state )
{
if ( state == QCheckBox::On )
{
static_cast<QCheckBox *>( child( "kcfg_ShowHiddenIPCShares", "QCheckBox" ) )->setEnabled( true );
static_cast<QCheckBox *>( child( "kcfg_ShowHiddenADMINShares", "QCheckBox" ) )->setEnabled( true );
}
else if ( state == QCheckBox::Off )
{
static_cast<QCheckBox *>( child( "kcfg_ShowHiddenIPCShares", "QCheckBox" ) )->setEnabled( false );
static_cast<QCheckBox *>( child( "kcfg_ShowHiddenADMINShares", "QCheckBox" ) )->setEnabled( false );
}
}
#include "smb4kuserinterfaceoptions.moc"

@ -0,0 +1,68 @@
/***************************************************************************
smb4kuserinterfaceoptions - This configuration page takes care
of all settings concerning the user interface of Smb4K
-------------------
begin : Mi Aug 30 2006
copyright : (C) 2006-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KUSERINTERFACEOPTIONS_H
#define SMB4KUSERINTERFACEOPTIONS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qtabwidget.h>
/**
* The configuration page for the user interface of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KUserInterfaceOptions : public QTabWidget
{
Q_OBJECT
public:
/**
* The constructor
*/
Smb4KUserInterfaceOptions( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KUserInterfaceOptions();
protected slots:
/**
* Enables/disables buttons according to the toggle state of the "Show hidden shares" button.
*
* @param state Describes the toggle state of the "Show hidden shares" checkbox.
*/
void slotShowHiddenShares( int state );
};
#endif

@ -0,0 +1,35 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
lib_LTLIBRARIES = libsmb4kcore.la
libsmb4kcore_la_LDFLAGS = -no-undefined $(all_libraries) -lkwalletclient \
-version-info 2:0:0
include_HEADERS = smb4kauthinfo.h smb4kbookmark.h smb4kbookmarkhandler.h \
smb4kcore.h smb4kdefs.h smb4kerror.h smb4kfileio.h smb4kglobal.h \
smb4khomesshareshandler.h smb4kmounter.h smb4knetworkitems.h \
smb4kpasswordhandler.h smb4kpreviewer.h smb4kpreviewitem.h \
smb4kprint.h smb4kprintinfo.h smb4ksambaoptionshandler.h \
smb4ksambaoptionsinfo.h smb4kscanner.h smb4kshare.h \
smb4ksynchronizationinfo.h smb4ksynchronizer.h
libsmb4kcore_la_SOURCES = smb4kauthinfo.cpp smb4kbookmark.cpp \
smb4kbookmarkhandler.cpp smb4kcore.cpp smb4kerror.cpp smb4kfileio.cpp smb4kglobal.cpp \
smb4kglobal_p.cpp smb4khomesshareshandler.cpp smb4kmounter.cpp smb4kmounter_p.cpp \
smb4knetworkitems.cpp smb4kpasswordhandler.cpp smb4kpreviewer.cpp smb4kpreviewitem.cpp \
smb4kprint.cpp smb4kprintinfo.cpp smb4ksambaoptionshandler.cpp \
smb4ksambaoptionsinfo.cpp smb4kscanner.cpp smb4kscanner_p.cpp smb4ksettings.kcfgc smb4kshare.cpp \
smb4ksynchronizationinfo.cpp smb4ksynchronizer.cpp
libsmb4kcore_la_LIBADD = $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(LIB_QT)
kde_kcfg_DATA = smb4k.kcfg
# Build rules
smb4kcore.lo: smb4ksettings.h
smb4kfileio.lo: smb4ksettings.h
smb4kmounter.lo: smb4ksettings.h
smb4kpasswordhandler.lo: smb4ksettings.h
smb4kprint.lo: smb4ksettings.h
smb4ksambaoptionshandler.lo: smb4ksettings.h
smb4kscanner.lo: smb4ksettings.h
smb4ksynchronizer.lo: smb4ksettings.h
noinst_HEADERS = smb4kglobal_p.h smb4kmounter_p.h smb4kscanner_p.h

@ -0,0 +1,998 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg>
<include>unistd.h</include>
<include>sys/types.h</include>
<include>qstring.h</include>
<kcfgfile name="smb4krc" />
<!-- Programs -->
<group name="Programs">
<entry name="grep" type="Path">
<label>The path to the program "grep"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="awk" type="Path">
<label>The path to the program "awk"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="sed" type="Path">
<label>The path to the program "sed"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="xargs" type="Path">
<label>The path to the program "xargs"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="rmdir" type="Path">
<label>The path to the program "rmdir"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="nmblookup" type="Path">
<label>The path to the program "nmblookup"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smbclient" type="Path">
<label>The path to the program "smbclient"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smbspool" type="Path">
<label>The path to the program "smbspool"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="net" type="Path">
<label>The path to the program "net"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="mount_cifs" type="Path">
<label>The path to the program "mount.cifs"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="umount_cifs" type="Path">
<label>The path to the program "umount.cifs"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smbmount" type="Path">
<label>The path to the program "smbmount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smbumount" type="Path">
<label>The path to the program "smbumount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="mount" type="Path">
<label>The path to the program "mount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="mount_smbfs" type="Path">
<label>The path to the program "mount_smbfs" (FreeBSD only)</label>
<whatsthis></whatsthis>
</entry>
<entry name="smbutil" type="Path">
<label>The path to the program "smbutil" (FreeBSD only)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="umount" type="Path">
<label>The path to the program "umount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smb4k_mount" type="Path">
<label>The path to the program "smb4k_mount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smb4k_umount" type="Path">
<label>The path to the program "smb4k_umount"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smb4k_kill" type="Path">
<label>The path to the program "smb4k_kill"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smb4k_cat" type="Path">
<label>The path to the program "smb4k_cat"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="smb4k_mv" type="Path">
<label>The path to the program "smb4k_mv"</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="super" type="Path">
<label>The path to the program "super" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="sudo" type="Path">
<label>The path to the program "sudo" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="dvips" type="Path">
<label>The path to the program "dvips" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="enscript" type="Path">
<label>The path to the program "enscript" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="rsync" type="Path">
<label>The path to the program "rsync" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
<entry name="konsole" type="Path">
<label>The path to the program "konsole" (optional)</label>
<whatsthis></whatsthis>
<!-- Default will be set by Smb4KCore::searchPrograms() -->
</entry>
</group>
<!-- User Interface -->
<group name="UserInterface">
<entry name="ShowCustomBookmarkLabel" type="Bool">
<label>Show custom bookmark label if available</label>
<whatsthis>Do not show the name of the share that is represented by the bookmark but the custom label that was defined in the bookmark editor.</whatsthis>
<default>true</default>
</entry>
<entry name="EmbedIntoSystemTray" type="Bool">
<label>Embed application into system tray</label>
<whatsthis>Embed the application into the system tray. The system tray widget provides a popup menu with several commonly used tasks so that you do not need to bring up the main window everytime. If this setting is chosen you have to use "Quit" from the "File" menu or the system tray widget to exit the application.</whatsthis>
<default>true</default>
</entry>
<entry name="StartMainWindowDocked" type="Bool">
<label>Start docked</label>
<whatsthis>Start the application docked to the system tray, i.e. only the system tray widget is shown and the main window is hidden. You can bring the main window up by clicking on the system tray widget or by choosing "Restore" from its popup menu.</whatsthis>
<default>false</default>
</entry>
<entry name="SharesView" type="Enum">
<label>How the shares should be displayed</label>
<whatsthis>Choose the kind of view you prefer for displaying the mounted shares. There is an icon view or a list view available.</whatsthis>
<choices>
<choice name="IconView"/>
<choice name="ListView"/>
</choices>
<default>IconView</default>
</entry>
<entry name="ShowPrinterShares" type="Bool">
<label>Show printer shares</label>
<whatsthis>Printer shares will be displayed in the network browser.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowHiddenShares" type="Bool">
<label>Show hidden shares</label>
<whatsthis>Hidden shares will be displayed in the network browser. Hidden shares are ending with a $ sign, e.g. Musik$ or IPC$.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowHiddenIPCShares" type="Bool">
<label>Show hidden IPC$ shares</label>
<whatsthis>Hidden IPC$ shares will be displayed in the network browser.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowHiddenADMINShares" type="Bool">
<label>Show hidden ADMIN$ shares</label>
<whatsthis>Hidden ADMIN$ shares will be displayed in the network browser.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowType" type="Bool">
<label>Show the type of a share</label>
<whatsthis>The type of a share will be displayed in a separate column in the network browser. It can either be Disk, Print or IPC.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowIPAddress" type="Bool">
<label>Show the IP address of a server</label>
<whatsthis>The IP address of the server will be displayed in a separate column in the network browser.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowComment" type="Bool">
<label>Show the comment of a share</label>
<whatsthis>The comment describing the server or share will be displayed in a separate column in the network browser.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowNetworkItemToolTip" type="Bool">
<label>Show a tooltip with information about the network item</label>
<whatsthis>The tooltip shows various information about the current network item.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowMountPoint" type="Bool">
<label>Show the mount point of a share instead of its name</label>
<whatsthis>A share is normally displayed with its name in the shares view. Choosing this feature will cause the exchange of the share name by the mount point.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowAllShares" type="Bool">
<label>Show all shares that are mounted on the system</label>
<whatsthis>You will not only see the shares that were mounted and are owned by you, but also all other mounts using the SMBFS and CIFS file system that are present on the system.</whatsthis>
<default>false</default>
</entry>
<entry name="EnableDropSupport" type="Bool">
<label>Allow the dropping of files and directories onto share icons</label>
<whatsthis>This setting allows you to drop files or whole directories onto the share icons, which will cause them to be copied.</whatsthis>
<default>false</default>
</entry>
<entry name="EnableDragSupport" type="Bool">
<label>Allow the dragging of share icons</label>
<whatsthis>This setting allows you to drag a share item out of Smb4K and onto the desktop or into a file manager. Only enable it if you think you absolutely need it and read the handbook before you mark this checkbox.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowShareToolTip" type="Bool">
<label>Show a tooltip with information about the share</label>
<whatsthis>The tooltip shows various information about the current share.</whatsthis>
<default>true</default>
</entry>
<entry name="PreviewHiddenItems" type="Bool">
<label>Show hidden files and directories when previewing a share</label>
<whatsthis>Display hidden files and directories in the preview dialog. The names of hidden files and directories are beginning with a period and are usually needed for very specific purposes (configuration file of an application, etc.). Since they are not of any importance for your regular work, you normally do not need to enable this feature.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowOwner" type="Bool">
<label>Show owner and group (SMBFS only)</label>
<whatsthis>Show the UID and GID that own all files on the mounted file system. At the moment the column will only contain an entry if the share was mounted with the SMBFS file system.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowLogin" type="Bool">
<label>Show login (CIFS only)</label>
<whatsthis>Show the login that was used to authenticate to the server. The column will only contain an entry if the share was mounted with the CIFS file system.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowFileSystem" type="Bool">
<label>Show file system</label>
<whatsthis>Show the file system that was used for mounting the share.</whatsthis>
<default>true</default>
</entry>
<entry name="ShowFreeDiskSpace" type="Bool">
<label>Show free disk space</label>
<whatsthis>Show the free disk space that is left on the share.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowUsedDiskSpace" type="Bool">
<label>Show used disk space</label>
<whatsthis>Show the disk space that is already used on the share.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowTotalDiskSpace" type="Bool">
<label>Show total disk space</label>
<whatsthis>Show the total disk space of the share.</whatsthis>
<default>false</default>
</entry>
<entry name="ShowDiskUsage" type="Bool">
<label>Show disk usage</label>
<whatsthis>Show the space that is used on the share in percent.</whatsthis>
<default>true</default>
</entry>
</group>
<!-- Network -->
<group name="Network">
<entry name="BrowseList" type="Enum">
<label>Method how to retrieve the browse list</label>
<whatsthis>Choose the method how to compile the initial browse list. There are four options available: The first one is the default one and employs "nmblookup -M -- -" to discover all workgroups, domains, and their master browsers on your network neighborhood. The second one instructs Smb4K to query the current master browser of your workgroup or domain to retrieve the browse list. The third is similar to the second one except that you can define the master browser that should be queried. If you choose the last option, the provided list of broadcast areas will be scanned using "nmblookup -B x.x.x.x -- '*'".</whatsthis>
<choices>
<choice name="LookupDomains"/>
<choice name="QueryCurrentMaster"/>
<choice name="QueryCustomMaster"/>
<choice name="ScanBroadcastAreas"/>
</choices>
<default>LookupDomains</default>
</entry>
<entry name="CustomMasterBrowser" type="String">
<label>A custom master browser that is to be queried</label>
<whatsthis>Enter the name or IP address of a master browser here that should be queried to compile the initial browse list.</whatsthis>
</entry>
<entry name="BroadcastAreas" type="String">
<label>A custom list of broadcast addresses</label>
<whatsthis>Enter a comma-separated list of broadcast addresses here (e.g. 192.168.0.255, 192.168.1.255). It is used to scan for all known hosts in the respective broadcast areas.</whatsthis>
</entry>
<entry name="SearchMethod" type="Enum">
<label>Method for searching for remote hosts</label>
<whatsthis>Smb4K is able to search for remote hosts either using nmblookup or smbclient. The nmblookup method is very reliable and works well. However, if your network is configured uncommonly and you experience problems when searching, you should try the smbclient method. But please note that you lose the ability to search for IP addresses in that case.</whatsthis>
<choices>
<choice name="Nmblookup"/>
<choice name="Smbclient"/>
</choices>
<default>Nmblookup</default>
</entry>
</group>
<!-- Shares -->
<group name="Shares">
<entry name="MountPrefix" type="Path">
<label>The mount prefix</label>
<whatsthis>This is the prefix where Smb4K will create the mount points and mount the remote shares.</whatsthis>
<default>${HOME}/smb4k/</default>
</entry>
<entry name="ForceLowerCaseSubdirs" type="Bool">
<label>Force the subdirectories created by Smb4K to be lowercase</label>
<whatsthis>All names of the subdirectories created by Smb4K below the mount prefix will be lowercase.</whatsthis>
<default>false</default>
</entry>
<entry name="UnmountSharesOnExit" type="Bool">
<label>Unmount the shares owned by the user on exit</label>
<whatsthis>Unmount all shares that belong to you when the program exits.</whatsthis>
<default>false</default>
</entry>
<entry name="RemountShares" type="Bool">
<label>Remount shares</label>
<whatsthis>Remount all your shares that were still mounted when you exited the program. Shares that were mounted by other users are ignored.</whatsthis>
<default>false</default>
</entry>
<entry name="UnmountForeignShares" type="Bool">
<label>Allow the unmounting of shares owned by other users</label>
<whatsthis>Allow the unmounting of shares that were mounted by other users. In most cases you need super user privileges for this. Please think before you enable this option!</whatsthis>
<default>false</default>
</entry>
<entry name="CheckInterval" type="Int">
<label>Interval between checks for new and inaccessible shares</label>
<whatsthis>This is the time that elapses until Smb4K checks again for new mounts and unmounts. The lower limit is 500 ms, the upper one 300000 ms. Please note that the smaller the interval gets the higher is your system load.</whatsthis>
<min>500</min>
<max>300000</max>
<default>2500</default>
</entry>
</group>
<!-- Authentication -->
<group name="Authentication">
<entry name="UseWallet" type="Bool">
<label>Use a wallet to store authentication data</label>
<whatsthis>Use a wallet to store the authentication data. The login name and the password name are stored encrypted on your hard drive. If this setting is disabled, the authentication data is not stored permanently but only temporarily.</whatsthis>
<default>true</default>
</entry>
<entry name="RememberPasswords" type="Bool">
<label>Remember passwords if no wallet is used</label>
<whatsthis>If you decided to store the login names and passwords only temporarily, Smb4K will remember them until the program exits. If you disable this setting, you will have to provide the authentication data everytime it is needed.</whatsthis>
<default>true</default>
</entry>
<entry name="UseDefaultLogin" type="Bool">
<label>Use a default login</label>
<whatsthis>Enable the usage of a default login name and password. The authentication data provided below is then used by default to authenticate to a remote server. This is very useful e.g. if you are working in an Active Directory environment or an NT domain.</whatsthis>
<default>false</default>
</entry>
<!-- <entry name="DefaultUserName" type="String">
<label>The default user name for authentication</label>
<whatsthis>This login name is used by default to authenticate to a remote server.</whatsthis>
</entry>
<entry name="DefaultPassword" type="String">
<label>The default password for authentication</label>
<whatsthis>This password is used by default to authenticate to a remote server. It may be empty.</whatsthis>
</entry>-->
</group>
<!-- Samba -->
<group name="Samba">
<entry name="NetBIOSName" type="String">
<label>The NetBIOS name of this computer</label>
<whatsthis>This is the NetBIOS name of this computer that is used by Smb4K. By default, it is either the NetBIOS name that is defined in the smb.conf file or the host name.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="DomainName" type="String">
<label>The name of the workgroup/domain this computer is in</label>
<whatsthis>This is the workgroup or domain this computer is or should be in. By default, it is the workgroup that is defined in the smb.conf file.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="SocketOptions" type="String">
<label>The socket options</label>
<whatsthis>These are the TCP socket options that are used by nmblookup, smbmount and smbclient. Socket options are controls on the networking layer of the operating systems which allow the connection to be tuned. See the manual page of smb.conf for more information.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="NetBIOSScope" type="String">
<label>The NetBIOS scope</label>
<whatsthis>This sets the NetBIOS scope that nmblookup, smbmount and smbclient will operate under. It should not be set unless every machine on your network neighborhood sets this value.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="RemotePort" type="Int">
<label>The remote SMB port</label>
<whatsthis>This is the port that is to be used for connecting to remote servers. Please note that this is independent of the settings in the smb.conf file.</whatsthis>
<min>1</min>
<max>65535</max>
<default>139</default>
</entry>
<entry name="UseKerberos" type="Bool">
<label>Use Kerberos for authentication</label>
<whatsthis>Try to authenticate with Kerberos. This is only useful in an Active Directory environment. The setting affects the smbmount and smbclient command.</whatsthis>
<default>false</default>
</entry>
<entry name="MachineAccount" type="Bool">
<label>Use machine account for login</label>
<whatsthis>Make queries to the remote server using the machine account of the local server. The setting affects the net and the smbclient command.</whatsthis>
<default>false</default>
</entry>
<entry name="Filesystem" type="Enum">
<label>The file system that is used for mounting remote shares</label>
<whatsthis>This is the file system that will be used to mount the remote shares. The Common Internet File System (CIFS) is supported by Windows 2000 and above as well as by Samba. It offers many improvements and advancements compared to the Server Message Block File System (SMBFS) which is used by Windows 9x and below.</whatsthis>
<choices>
<choice name="CIFS"/>
<choice name="SMBFS"/>
</choices>
<default>CIFS</default>
</entry>
<entry name="ClientCharset" type="Enum">
<label>The charset used by the client</label>
<whatsthis>This is the charset that is used by the client side (i.e. your side) either to convert local path names to and from Unicode in case of the CIFS file system or for codepage to charset translations (NLS) in case of the SMBFS file system. If you keep the default setting, Smb4K will try to automatically determine the charset by looking up the "unix charset" option in the smb.conf.</whatsthis>
<choices>
<choice name="default_charset"/>
<choice name="iso8859_1"/>
<choice name="iso8859_2"/>
<choice name="iso8859_3"/>
<choice name="iso8859_4"/>
<choice name="iso8859_5"/>
<choice name="iso8859_6"/>
<choice name="iso8859_7"/>
<choice name="iso8859_8"/>
<choice name="iso8859_9"/>
<choice name="iso8859_13"/>
<choice name="iso8859_14"/>
<choice name="iso8859_15"/>
<choice name="utf8"/>
<choice name="koi8_r"/>
<choice name="koi8_u"/>
<choice name="koi8_ru"/>
<choice name="cp1251"/>
<choice name="gb2312"/>
<choice name="big5"/>
<choice name="euc_jp"/>
<choice name="euc_kr"/>
<choice name="tis_620"/>
</choices>
<default>default_charset</default>
</entry>
<entry name="ServerCodepage" type="Enum">
<label>The codepage used by the server</label>
<whatsthis>This is the codepage that is used by the server. The setting is only available with the SMBFS file system. If you keep the default setting, Smb4K will try to automatically determine the codepage by looking up the "dos charset" option in the smb.conf.</whatsthis>
<choices>
<choice name="default_codepage"/>
<choice name="cp437"/>
<choice name="cp720"/>
<choice name="cp737"/>
<choice name="cp775"/>
<choice name="cp850"/>
<choice name="cp852"/>
<choice name="cp855"/>
<choice name="cp857"/>
<choice name="cp858"/>
<choice name="cp860"/>
<choice name="cp861"/>
<choice name="cp862"/>
<choice name="cp863"/>
<choice name="cp864"/>
<choice name="cp865"/>
<choice name="cp866"/>
<choice name="cp869"/>
<choice name="cp874"/>
<choice name="cp932"/>
<choice name="cp936"/>
<choice name="cp949"/>
<choice name="cp950"/>
<choice name="cp1250"/>
<choice name="cp1251"/>
<choice name="cp1252"/>
<choice name="cp1253"/>
<choice name="cp1254"/>
<choice name="cp1255"/>
<choice name="cp1256"/>
<choice name="cp1257"/>
<choice name="cp1258"/>
<choice name="unicode"/>
</choices>
<default>default_codepage</default>
</entry>
<entry name="UserID" type="String">
<label>The user ID that is to be used for mounting</label>
<whatsthis>Here you can enter the user ID (a number) that the files and directories of the mounted share will have. If you are using the CIFS file system and the remote server supports the CIFS Unix Extentions, this setting will be ignored.</whatsthis>
<default code="true">QString( "%1" ).arg( (int)getuid() )</default>
</entry>
<entry name="GroupID" type="String">
<label>The group ID that is to be used for mounting</label>
<whatsthis>Here you can enter the group ID (a number) that the files and directories of the mounted share will have. If you are using the CIFS file system and the remote server supports the CIFS Unix Extentions, this setting will be ignored.</whatsthis>
<default code="true">QString( "%1" ).arg( (int)getgid() )</default>
</entry>
<entry name="FileMask" type="String">
<label>The file mask for a share</label>
<whatsthis>This is the mask that will be used for creating files. It must be defined in octal. In case the CIFS file system is used, this setting only takes effect if the server does not support the CIFS Unix Extensions.</whatsthis>
<default>0755</default>
</entry>
<entry name="DirectoryMask" type="String">
<label>The directory mask for a share</label>
<whatsthis>This is the mask that will be used for creating directories. It must be defined in octal. In case the CIFS file system is used, this setting only takes effect if the server does not support the CIFS Unix Extensions.</whatsthis>
<default>0755</default>
</entry>
<entry name="WriteAccess" type="Enum">
<label>The write access granted for the share</label>
<whatsthis>Here you can choose if the shares should be mounted in read and write mode or only read-only.</whatsthis>
<choices>
<choice name="ReadWrite"/>
<choice name="ReadOnly"/>
</choices>
<default>ReadWrite</default>
</entry>
<entry name="PermissionChecks" type="Bool">
<label>Do permission checks</label>
<whatsthis>The client side (i.e. your side) will check if you have the right UID/GID to manipulate a file or directory. You might want to switch this feature off if the server(s) support the CIFS Unix Extensions and you are not allowed to access the files and directories. This setting does not affect the normal ACL check.</whatsthis>
<default>true</default>
</entry>
<entry name="ClientControlsIDs" type="Bool">
<label>Set UID and GID</label>
<whatsthis>In case the server supports the CIFS Unix Extensions, the client side (i.e. your side) attempts to set the effective UID and GID of the current process on newly created files, directories and devices. If this feature is turned off, the default UID and GID defined for the share will be used. It is recommended that you read the manual page of mount.cifs before you change this setting.</whatsthis>
<default>false</default>
</entry>
<entry name="ServerInodeNumbers" type="Bool">
<label>Use server inode numbers</label>
<whatsthis>Use inode numbers (unique persistent file identifiers) returned by the server instead of automatically generating temporary inode numbers on the client side.</whatsthis>
<default>false</default>
</entry>
<entry name="InodeDataCaching" type="Bool">
<label>Do not cache inode data</label>
<whatsthis>Directly read from and write to files opened on the share. In some cases this can provide better performance than the default behavior which caches reads and writes.</whatsthis>
<default>false</default>
</entry>
<entry name="TranslateReservedChars" type="Bool">
<label>Translate reserved characters</label>
<whatsthis>Translate six of the seven reserved characters (including the colon, question mark, pipe, asterisk, greater than and less than characters but not the backslash) to remap range (above 0xF000). This allows you to open files that were created with such characters. This has no effect if the server does not support Unicode.</whatsthis>
<default>false</default>
</entry>
<entry name="NoLocking" type="Bool">
<label>Do not use locking</label>
<whatsthis>Do not use locking. Do not start lockd.</whatsthis>
<default>false</default>A
</entry>
<entry name="CustomCIFSOptions" type="String">
<label>Advanced custom options for the CIFS file system</label>
<whatsthis>Here you can enter advanced options for the CIFS file system in a comma-separated list (refer to the manual page of mount.cifs to learn more). The list will be added AS IS to the "-o" argument of mount.cifs. Please do not enter options that have already been defined in the configuration dialog.</whatsthis>
<default></default>
</entry>
<entry name="CachingTime" type="Int">
<label>Determines how long directory listings are cached</label>
<whatsthis>This setting determines how long a directory listing is cached in milliseconds. A high value means it takes longer until changes on the server are noticed on the client side (i.e. your side), but it can also give you an increase in performance on large directories, especially on long distances. You need Linux kernel 2.4.2 or later to take advantage of this setting.</whatsthis>
<default>1000</default>
</entry>
<entry name="UnicodeSupport" type="Bool">
<label>Unicode support</label>
<whatsthis>Use Unicode when communicating with the server. This will give you better support for non-ASCII character sets with the SMBFS file system.</whatsthis>
<default>false</default>
</entry>
<entry name="LargeFileSystemSupport" type="Bool">
<label>Long file support</label>
<whatsthis>Large file support (LFS) enables you to read and write
files bigger than 2 GB on shares that were mounted with the SMBFS file system.</whatsthis>
<default>false</default>
</entry>
<entry name="ProtocolHint" type="Enum">
<label>The protocol that is used with the net command</label>
<whatsthis>Here you can choose the protocol that will be used by the net command for the communication with remote servers if appropriate. In most cases the automatic detection will work fine and you should not need to change the default setting. However, if you experience problems, use the RPC protocol for newer operating systems (Windows NT4 and above) and the RAP protocol for older ones (Windows 98/NT3 and below). Functions that need the ADS protocol (for Active Directory environments) have not been implemented yet, so you can ignore that one for now.</whatsthis>
<choices>
<choice name="Automatic"/>
<choice name="RPC"/>
<choice name="RAP"/>
<choice name="ADS"/>
</choices>
<default>Automatic</default>
</entry>
<entry name="NameResolveOrder" type="String">
<label>Name resolve order used by smbclient</label>
<whatsthis>This option is used to determine what naming services and in what order are used to resolve host names and IP addresses. It takes a space-separated list of up to four different name resolution options. Those are: lmhost, host, wins, bcast. See the manual page of smbclient for further information.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="BufferSize" type="Int">
<label>Transmit/send buffer size used by smbclient</label>
<whatsthis>This option changes the transmit/send buffer size when getting or putting a file from/to the server. The default is 65520 bytes. Setting this value smaller has been observed to speed up file transfers to and from Windows 9x servers.</whatsthis>
<min>0</min>
<default>65520</default>
</entry>
<entry name="SigningState" type="Enum">
<label>Signing state</label>
<whatsthis>Set the signing state for smbclient.</whatsthis>
<choices>
<choice name="None"/>
<choice name="On"/>
<choice name="Off"/>
<choice name="Required"/>
</choices>
<default>None</default>
</entry>
<entry name="BroadcastAddress" type="String">
<label>The broadcast address used by nmblookup</label>
<whatsthis>Queries performed with nmblookup will be send to the given broadcast address. Without this option the default behavior is to send the queries to the broadcast address of the network interface that was either auto-detected or defined in the "interfaces" parameter of the smb.conf file.</whatsthis>
<!-- Will be filled by Smb4KCore::setDefaultConfigValues() -->
</entry>
<entry name="UsePort137" type="Bool">
<label>Use UDP port 137 with nmblookup</label>
<whatsthis>Try and bind to UDP port 137 to send and receive UDP datagrams. The reason for this option is a bug in Windows 95 where it ignores the source port of the requesting packet and only replies to UDP port 137. Unfortunately, on most Unix systems super user privileges are needed to bind to this port. Please read the manual page of nmblookup for more information.</whatsthis>
<default>false</default>
</entry>
<!-- The custom tab is filled by the core -->
</group>
<!-- Synchronization -->
<!-- Many <whatsthis></whatsthis> entries contain excerpts from the rsync
manual page (version 2.6.9). -->
<group name="Synchronization">
<entry name="RsyncPrefix" type="Path">
<label>Prefix for synchronization</label>
<whatsthis>This is the path where Smb4K will store the files and directories during synchronization. If you plan to synchronize only with one remote share, then you can put the data directly in this directory. If you want to synchronize with several remote shares, then you should create a subdirectory for each share and choose the appropriate one in the synchronization dialog.</whatsthis>
<default>$HOME/smb4k_sync/</default>
</entry>
<entry name="ArchiveMode" type="Bool">
<label>Use archive mode</label>
<whatsthis>Use archive mode (-a, --archive). This is a short form of -rlptgoD.</whatsthis>
<default>true</default>
</entry>
<entry name="RecurseIntoDirectories" type="Bool">
<label>Recurse into subdirectories</label>
<whatsthis>Recurse into directories (-r, --recursive).</whatsthis>
<default>true</default>
</entry>
<entry name="UpdateTarget" type="Bool">
<label>Skip files that are newer in the target directory</label>
<whatsthis>Update files in the destination directory that are older than in the source directory (-u, --update).</whatsthis>
<default>true</default>
</entry>
<entry name="UpdateInPlace" type="Bool">
<label>Update destination files in place</label>
<whatsthis>Update destination files in-place (--inplace). By default, rsync first creates a new copy of a file and moves it into place after its transfer finished. If you enable this feature, no copy will be created but the destination file will immediately be overwritten instead. An exception to this is if you combine this option with --backup.</whatsthis>
<default>false</default>
</entry>
<entry name="RelativePathNames" type="Bool">
<label>Use relative path names</label>
<whatsthis>Use relative paths (-R, --relative). This means that the full path names specified on the command line are sent to the server rather than just the last parts of the file names.</whatsthis>
<default>false</default>
</entry>
<entry name="NoImpliedDirectories" type="Bool">
<label>Don't send implied directories with --relative</label>
<whatsthis>Don't send implied directories with --relative (--no-implied-dirs). This means that the corresponding path elements on the destination system are left unchanged if they exist, and any missing implied directories are created with default attributes. This even allows these implied path elements to have big differences, such as being a symlink to a directory on one side of the transfer, and a real directory on the other side.</whatsthis>
<default>false</default>
</entry>
<entry name="TransferDirectories" type="Bool">
<label>Transfer directories without recursing</label>
<whatsthis>Transfer directories without recursing (-d, --dirs). This means that all top-level subdirectories are transferred but without their contents.</whatsthis>
<!-- This description is only correct for Smb4K. See manual page for further information. -->
<default>false</default>
</entry>
<entry name="CompressData" type="Bool">
<label>Compress data during transfer</label>
<whatsthis>Compress data during transfer (-z, --compress). This significantly reduces the amount of data that is being transferred. You may want to use this option, if you have a slow connection.</whatsthis>
<default>false</default>
</entry>
<entry name="PreserveSymlinks" type="Bool">
<label>Preserve symlinks</label>
<whatsthis>Copy symlinks as symlinks (-l, --links).</whatsthis>
<default>true</default>
</entry>
<entry name="TransformSymlinks" type="Bool">
<label>Transform symlinks</label>
<whatsthis>Transform symlinks into the items they are pointing to (-L, --copy-links).</whatsthis>
<default>false</default>
</entry>
<entry name="TransformUnsafeSymlinks" type="Bool">
<label>Only transform unsafe symlinks</label>
<whatsthis>Transform unsafe symlinks into the items they are pointing to (--copy-unsafe-links). This means that only those symlinks are transformed that point to items that are outside the copied tree. Absolute symlinks are treated the same way. This option has no additional effect if --copy-links has also been specified.</whatsthis>
<default>false</default>
</entry>
<entry name="IgnoreUnsafeSymlinks" type="Bool">
<label>Ignore unsafe symlinks</label>
<whatsthis>Ignore symlinks that point outside the copied tree (--safe-links). All absolute symlinks are also ignored. If you use this option in conjunction with --relative you might get unexpected results.</whatsthis>
<default>false</default>
</entry>
<entry name="PreserveHardLinks" type="Bool">
<label>Preserve hard links</label>
<whatsthis>Preserve hard links (-H, --hard-links). This options causes rsync to preserve the hard links that are found during the transfer. Without it, hard links are treated as though they were separate files.</whatsthis>
<default>false</default>
</entry>
<entry name="KeepDirectorySymlinks" type="Bool">
<label>Keep directory symlinks</label>
<whatsthis>Treat symlinked directories on the receiving side as though they were real ones (-K, --keep-dirlinks). This only works if the symlink matches a real directory from the sending side. Without this option, the receiver's symlink will be deleted and replaced with a real directory.</whatsthis>
<default>false</default>
</entry>
<entry name="PreservePermissions" type="Bool">
<label>Preserve permissions</label>
<whatsthis>Preserve permissions (-p, --perms). The permissions of the destination file will be same as the source file. For what happens if this option is switched off, please read rsync's manual page.</whatsthis>
<default>true</default>
</entry>
<entry name="PreserveGroup" type="Bool">
<label>Preserve group</label>
<whatsthis>Preserve the group (-g, --group). The group of the destination file will be set to the same value as the source file.</whatsthis>
<default>true</default>
</entry>
<entry name="PreserveOwner" type="Bool">
<label>Preserve owner (super user only)</label>
<whatsthis>Preserve the owner (-o, --owner). The owner of the destination file will be set to the same value as the source file, but only if the receiving rsync is run as the super user. Without this option, the owner is set to the invoking user on the receiving side.</whatsthis>
<default>true</default>
</entry>
<entry name="PreserveDevicesAndSpecials" type="Bool">
<label>Preserve device and special files</label>
<whatsthis>Preserve device and special files (-D, --devices --specials). This option causes rsync to transfer character and block devices as well as special files such as named sockets and fifos. It works only partially if rsync is not run as super user and the --super option is not specified.</whatsthis>
<default>true</default>
</entry>
<entry name="PreserveTimes" type="Bool">
<label>Preserve times</label>
<whatsthis>Preserve times (-t, --times). The modification times are transferred along with the files. For what happens if this option is switched off, please read rsync's manual page.</whatsthis>
<default>true</default>
</entry>
<entry name="OmitDirectoryTimes" type="Bool">
<label>Omit directories when preserving times</label>
<whatsthis>Omit directories when preserving times (-O, --omit-dir-times). This means that directories are omitted when modification times are being preserved. Thus, this feature only works in conjunction with --times.</whatsthis>
<default>false</default>
</entry>
<entry name="RemoveSourceFiles" type="Bool">
<label>Remove synchronized source files</label>
<whatsthis>Remove all synchronized source files (--remove-source-files). This tells rsync to remove from the sending side the non-directory items that are a part of the transfer and have been successfully duplicated on the receiving side.</whatsthis>
<default>false</default>
</entry>
<entry name="DeleteExtraneous" type="Bool">
<label>Delete extraneous files</label>
<whatsthis>Delete extraneous files from destination (--delete). This tells rsync to delete all files from the receiving side that are not present on the sending side, but only for the directories that are being synchronized.</whatsthis>
<default>false</default>
</entry>
<entry name="DeleteBefore" type="Bool">
<label>Delete files before transfer</label>
<whatsthis>Delete files on the receiving side before the transfer starts (--delete-before). This is the default behavior if --delete or --delete-excluded is specified without one of the --delete-WHEN options.</whatsthis>
<default>false</default>
</entry>
<entry name="DeleteAfter" type="Bool">
<label>Delete files after transfer</label>
<whatsthis>Delete files on the receiving side after the transfer has completed (--delete-after, --del).</whatsthis>
<default>false</default>
</entry>
<entry name="DeleteDuring" type="Bool">
<label>Delete files during transfer</label>
<whatsthis>Delete files on the receiving side during the transfer (--delete-during). This method is faster than --delete-before or --delete-after, but it is only supported with rsync 2.6.4 or later.</whatsthis>
<default>false</default>
</entry>
<entry name="DeleteExcluded" type="Bool">
<label>Also delete excluded files from destination directory</label>
<whatsthis>Also delete excluded files from destination directory (--delete-excluded). In addition to deleting the files on the receiving side that are not on the sending side, this tells rsync to also delete any files on the receiving side that are excluded. Refer to rsync's manual page for further information.</whatsthis>
<default>false</default>
</entry>
<entry name="IgnoreErrors" type="Bool">
<label>Delete even if I/O errors occur</label>
<whatsthis>Delete even if I/O errors occur (--ignore-errors). This option has to be specified in conjunction with --delete to take effect.</whatsthis>
<default>false</default>
</entry>
<entry name="ForceDirectoryDeletion" type="Bool">
<label>Force deletion of non-void directories</label>
<whatsthis>Force deletion of directories even if they are not empty (--force). This option tells rsync to delete a non-empty directory when it is to be replaced by a non-directory. This is only relevant if deletions are not active.</whatsthis>
<default>false</default>
</entry>
<entry name="UseMaximumDelete" type="Bool">
<label>Only delete a maximum number of files</label>
<whatsthis>Only delete as many files as defined here (--max-delete=NUM). This tells rsync not to delete more than NUM files or directories (NUM must be non-zero). This is useful when mirroring very large trees to prevent disasters.</whatsthis>
<default>false</default>
</entry>
<entry name="MaximumDeleteValue" type="Int">
<label>Value for DeleteMaximum config entry</label>
<whatsthis></whatsthis>
<min>0</min>
<default>0</default>
</entry>
<entry name="UseMinimalTransferSize" type="Bool">
<label>Don't transfer any file smaller than SIZE</label>
<whatsthis>This option causes rsync to not transfer any file that is smaller than the specified size (--min-size=SIZE).</whatsthis>
<default>false</default>
</entry>
<entry name="MinimalTransferSize" type="Int">
<label>Value for MinimalTransferSize config entry</label>
<whatsthis></whatsthis>
<min>0</min>
<default>0</default>
</entry>
<entry name="UseMaximalTransferSize" type="Bool">
<label>Don't transfer any file smaller than SIZE</label>
<whatsthis>This option causes rsync to not transfer any file that is larger than the specified size (--max-size=SIZE).</whatsthis>
<default>false</default>
</entry>
<entry name="MaximalTransferSize" type="Int">
<label>Value for MamximalTransferSize config entry</label>
<whatsthis></whatsthis>
<min>0</min>
<default>0</default>
</entry>
<entry name="KeepPartial" type="Bool">
<label>Keep partially transferred files</label>
<whatsthis>Keep partially transferred files (--partial). The default behavor is that any partially transferred file is deleted if the transfer is interrupted.</whatsthis>
<default>false</default>
</entry>
<entry name="UsePartialDirectory" type="Bool">
<label>The directory where to put a partially transferred file into.</label>
<whatsthis>Put a partially transferred file into this directory (--partial-dir=DIR). This is a better way than the --partial option to keep partial files, because the partially transferred file is kept in a different directory and the destination file is not overwritten.</whatsthis>
<default>false</default>
</entry>
<entry name="PartialDirectory" type="Path">
<label>The data for the UsePartialDirectory option</label>
<whatsthis></whatsthis>
<default>$HOME</default>
</entry>
<entry name="UseCVSExclude" type="Bool">
<label>Auto-ignore files in the same way CVS does</label>
<whatsthis>Auto-ignore files in the same way CVS does (-C, --cvs-exclude). This is a useful shorthand for excluding a broad range of files that you often do not want to transfer between systems. This option uses the same algorithm that CVS uses to determine if a file should be ignored.</whatsthis>
<default>false</default>
</entry>
<entry name="UseExcludePattern" type="Bool">
<label>Exclude files that match a certain pattern</label>
<whatsthis>Exclude files that match a certain pattern (--exclude=PATTERN). This is a special filter rule. For further information on filter rules see rsync's manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="ExcludePattern" type="String">
<label>Pattern that is used for file exclusion</label>
<whatsthis></whatsthis>
<default></default>
</entry>
<entry name="UseExcludeFrom" type="Bool">
<label>Read exclude patterns from a file</label>
<whatsthis>Read exclude patterns from a file (--exclude-from=FILE). This option is similar to the --exclude=PATTERN option except that the exclude patterns are read from a file. This is a special filter rule. For further information on filter rules see rsync's manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="ExcludeFrom" type="Path">
<label>The file from which the exclude patterns are read</label>
<whatsthis></whatsthis>
<default>$HOME/exclude.txt</default>
</entry>
<entry name="UseIncludePattern" type="Bool">
<label>Do not exclude files matching a certain pattern</label>
<whatsthis>Do not exclude files matching a certain pattern (--include=PATTERN). This is a special filter rule. For further information on filter rules see rsync's manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="IncludePattern" type="String">
<label>Pattern that is used for file inclusion</label>
<whatsthis></whatsthis>
<default></default>
</entry>
<entry name="UseIncludeFrom" type="Bool">
<label>Read include patterns from a file</label>
<whatsthis>Read include patterns from a file (--include-from=FILE). This option is similar to the --include=PATTERN option except that the include patterns are read from a file. This is a special filter rule. For further information on filter rules see rsync's manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="IncludeFrom" type="Path">
<label>The file from which the include patterns are read</label>
<whatsthis></whatsthis>
<default>$HOME/include.txt</default>
</entry>
<entry name="CustomFilteringRules" type="String">
<label>Add custom file-filtering rules</label>
<whatsthis>Add custom file-filtering rules (-f, --filter=RULE). This option allows you to add rules to selectively exclude certain files from the list of files to be transferred.</whatsthis>
<default></default>
</entry>
<entry name="UseFFilterRule" type="Bool">
<label>Use -F filter rule</label>
<whatsthis>This filter rule tells rsync to look for per-directory .rsync-filter files that have been sprinkled through the hierarchy and use their rules to filter the files in the transfer. It has no effect, if you also choose to use the --filter='exclude .rsync-filter' rule.</whatsthis>
<default>false</default>
</entry>
<entry name="UseFFFilterRule" type="Bool">
<label>Use -FF filter rule</label>
<whatsthis>This rule filters out the .rsync-filter files from the transfer. These files normally contain filter rules that can be activated by choosing the --filter='dir-merge /.rsync-filter' rule and deselecting this one.</whatsthis>
<default>false</default>
</entry>
<entry name="EfficientSparseFileHandling" type="Bool">
<label>Handle sparse files efficiently</label>
<whatsthis>Handle sparse files efficiently (-S, --sparse) so that they take up less space on the destination. This option conflicts with --inplace. For further information read rsync's manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="CopyFilesWhole" type="Bool">
<label>Copy files whole (no rsync algorithm)</label>
<whatsthis>Copy files whole (-W, --whole-file). With this option the incremental rsync algorithm is not used and the whole file is sent as-is instead.</whatsthis>
<default>false</default>
</entry>
<entry name="OneFileSystem" type="Bool">
<label>Do not cross file system boundaries</label>
<whatsthis>Do not cross file system boundaries (-x, --one-file-system). This tells rsync to avoid crossing a filesystem boundary when recursing. For further information on this option, read the manual page.</whatsthis>
<default>false</default>
</entry>
<entry name="UpdateExisting" type="Bool">
<label>Skip creating new files on the receiving side</label>
<whatsthis>Skip creating new files on the receiving side (--existing). This tells rsync to skip creating files (including directories) that do not exist yet on the destination. If this option is combined with the --ignore-existing option, no files will be updated (which can be useful if all you want to do is to delete extraneous files).</whatsthis>
<default>false</default>
</entry>
<entry name="IgnoreExisting" type="Bool">
<label>Skip updating files that exist on the receiving side</label>
<whatsthis>Skip updating files that already exist on the receiving side (--ignore-existing). Existing directories are not ignored.</whatsthis>
<default>false</default>
</entry>
<entry name="DelayUpdates" type="Bool">
<label>Delay updates until the end of the transfer</label>
<whatsthis>Delay updates until the end of the transfer (--delay-updates). This option puts the temporary file from each updated file into a holding directory until the end of the transfer, at which time all the files are renamed and copied into place in rapid succession.</whatsthis>
<default>false</default>
</entry>
<entry name="MakeBackups" type="Bool">
<label>Make backups</label>
<whatsthis>Make backups (-b, --backup). With this option, preexisting destination files are renamed as each file is transferred or deleted. You can control where the backup file goes and what (if any) suffix gets appended using the --backup-dir=DIR and --suffix=SUFFIX options.</whatsthis>
<default>false</default>
</entry>
<entry name="UseBackupSuffix" type="Bool">
<label>Use a suffix for backups</label>
<whatsthis>Use this suffix for backups (--suffix=SUFFIX).</whatsthis>
<default>false</default>
</entry>
<entry name="BackupSuffix" type="String">
<label>Backup suffix</label>
<whatsthis></whatsthis>
<default>~</default>
</entry>
<entry name="UseBackupDirectory" type="Bool">
<label>Put backups into a certain directory</label>
<whatsthis>Store backups in this directory (--backup-dir=DIR).</whatsthis>
<default>false</default>
</entry>
<entry name="BackupDirectory" type="Path">
<label>Backup directory</label>
<whatsthis></whatsthis>
<default>$HOME</default>
</entry>
<entry name="UseBlockSize" type="Bool">
<label>Force a fixed checksum block-size</label>
<whatsthis>Force a fixed checksum block-size (-B, --block-size=SIZE). This forces the block size used in the rsync algorithm to a fixed value.</whatsthis>
<default>false</default>
</entry>
<entry name="BlockSize" type="Int">
<label>The block size</label>
<whatsthis></whatsthis>
<min>0</min>
<default>0</default>
</entry>
<entry name="UseChecksumSeed" type="Bool">
<label>Set block/file checksum seed</label>
<whatsthis>Set block/file checksum seed (--checksum-seed=NUM). Set the MD4 checksum seed to this integer. This 4 byte checksum seed is included in each block and file MD4 checksum calculation. By default the checksum seed is generated by the server and defaults to the current time.</whatsthis>
<default>false</default>
</entry>
<entry name="ChecksumSeed" type="Int">
<label>The checksum seed</label>
<whatsthis></whatsthis>
<min>0</min>
<default>0</default>
</entry>
<entry name="UseChecksum" type="Bool">
<label>Skip files based on a checksum</label>
<whatsthis>Skip files based on a checksum and not based on modification time and size (-c, --checksum). For further information on how this feature works read rsync's manual page.</whatsthis>
<default>false</default>
</entry>
</group>
<!-- Super User -->
<group name="SuperUser">
<entry name="SuperUserProgram" type="Enum">
<label>The program that should be used to gain super user privileges</label>
<whatsthis>Choose the program that will grant you limited super user privileges for mounting and unmounting remote shares. You can either select sudo, the standard tool for this purpose on most distributions, or super.</whatsthis>
<choices>
<choice name="Sudo"/>
<choice name="Super"/>
</choices>
<default>Sudo</default>
</entry>
<entry name="UseForceUnmount" type="Bool">
<label>Use super user privileges to unmount inaccessible shares</label>
<whatsthis>Unmount a share under Linux by force. This even works if the file system is "busy", because it is immediately detached from the file system hierarchy and all references to it are cleaned up later when it is not busy anymore. Linux kernel 2.4.11 or later is needed to take advantage of this feature. Use with case! Note, that you will need the root password to write the necessary changes to the configuration file.</whatsthis>
<default>false</default>
</entry>
<entry name="AlwaysUseSuperUser" type="Bool">
<label>Use super user privileges to mount and unmount shares</label>
<whatsthis>Use super user privileges for mounting and unmounting remote shares. This feature is only needed, if you are not allowed to use smbmount, smbumount, mount.cifs and umount.cifs as normal user. Note, that you will need the root password to write the necessary changes to the configuration file.</whatsthis>
<default>false</default>
</entry>
</group>
</kcfg>

@ -0,0 +1,63 @@
/***************************************************************************
smb4kauthinfo.cpp - This class provides a container for the
authentication data.
-------------------
begin : Sa Feb 28 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// application specific includes
#include "smb4kauthinfo.h"
Smb4KAuthInfo::Smb4KAuthInfo( const QString &wg, const QString &h, const QString &s, const QString &u, const QString &p ) : m_workgroup(wg), m_host(h), m_share(s), m_user(u.local8Bit()), m_password(p.local8Bit())
{
}
Smb4KAuthInfo::Smb4KAuthInfo( Smb4KAuthInfo &i ) : m_workgroup( i.workgroup() ), m_host( i.host() ), m_share( i.share() ), m_user( i.user() ), m_password( i.password() )
{
}
Smb4KAuthInfo::~Smb4KAuthInfo()
{
}
void Smb4KAuthInfo::setUser( const QString &user )
{
m_user = user.local8Bit();
}
void Smb4KAuthInfo::setPassword( const QString &passwd )
{
m_password = passwd.local8Bit();
}
void Smb4KAuthInfo::setShare( const QString &share )
{
m_share = share;
}

@ -0,0 +1,148 @@
/***************************************************************************
smb4kauthinfo.h - This class provides a container for the
authentication data.
-------------------
begin : Sa Feb 28 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KAUTHINFO_H
#define SMB4KAUTHINFO_H
// Qt includes
#include <qstring.h>
#include <qcstring.h>
/**
* This class provides a container for the authentication data.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KAuthInfo
{
public:
/**
* The constructor.
*
* @param workgroup The workgroup of the share the auth info is for.
*
* @param hosts The host's name
*
* @param share The share's name
*
* @param user The username that's used for authentication. Default is QString::null.
*
* @param password The password that's used for authentication. Default is QString::null.
*/
Smb4KAuthInfo( const QString &workgroup,
const QString &host,
const QString &share,
const QString &user = QString::null,
const QString &password = QString::null );
/**
* The empty constructor.
*/
Smb4KAuthInfo() {}
/**
* The copy constructor.
*
* @param info The Smb4KAuthInfo object that will be copied.
*/
Smb4KAuthInfo( Smb4KAuthInfo &info );
/**
* The destructor
*/
~Smb4KAuthInfo();
/**
* Returns the name of the workgroup.
*
* @returns The workgroup of the server/share for which this
* authentication data is for.
*/
const QString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the server (host).
*
* @returns The server name
*/
const QString &host() const { return m_host; }
/**
* Returns the name of the share.
*
* @returns The share name
*/
const QString &share() const { return m_share; }
/**
* Returns the user's name.
*
* @returns The user name
*/
const QCString &user() const { return m_user; }
/**
* Returns the (unescaped) password.
*/
const QCString &password() const { return m_password; }
/**
* Sets the user name.
*
* @param user The user name for the server/share
*/
void setUser( const QString &user );
/**
* Sets the password.
*
* @param passwd The password for the server/share
*/
void setPassword( const QString &passwd );
/**
* Sets the share name.
*
* @param share The name of the share
*/
void setShare( const QString &share );
private:
/**
* The workgroup object.
*/
QString m_workgroup;
/**
* The host object.
*/
QString m_host;
/**
* The share object.
*/
QString m_share;
/**
* The user name for this share.
*/
QCString m_user;
/**
* The password object for this share.
*/
QCString m_password;
};
#endif

@ -0,0 +1,97 @@
/***************************************************************************
smb4kbookmark.cpp - A bookmark container.
-------------------
begin : Feb 04 2004
copyright : (C) 2004 by Franck Babin
(C) 2005-2007 by Alexander Reinholdt
email : babinfranck@yahoo.ca
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 <ksocketaddress.h>
// application specific includes
#include "smb4kbookmark.h"
#include "smb4knetworkitems.h"
Smb4KBookmark::Smb4KBookmark( const QString &host, const QString &share, const QString &workgroup, const QString &ip, const QString &type, const QString &label )
: m_host( host ), m_share( share ), m_workgroup( workgroup ), m_type( type ), m_label( label )
{
//FIXME should throw an exception if one of the param is empty
m_ip = ipIsValid( ip ) ? ip : QString::null;
m_bookmark = QString( "//%1/%2" ).arg( m_host, m_share );
}
Smb4KBookmark::Smb4KBookmark( Smb4KShareItem *item, const QString &ip, const QString &label )
: m_host( item->host() ), m_share( item->name() ), m_workgroup( item->workgroup() ),
m_type( item->plainType() ), m_label( label )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
m_bookmark = QString( "//%1/%2" ).arg( m_host, m_share );
}
Smb4KBookmark::~Smb4KBookmark()
{
}
void Smb4KBookmark::setShareName( const QString &name )
{
m_share = name;
m_bookmark = QString( "//%1/%2" ).arg( m_host, m_share );
}
void Smb4KBookmark::setIP( const QString &ip )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
void Smb4KBookmark::setLabel( const QString &text )
{
m_label = text;
}
bool Smb4KBookmark::ipIsValid( const QString &ip )
{
if ( !ip.isEmpty() )
{
KNetwork::KIpAddress ip_address = KNetwork::KIpAddress( ip );
if ( !ip_address.isIPv4Addr() && !ip_address.isIPv6Addr() )
{
return false;
}
}
else
{
return false;
}
return true;
}

@ -0,0 +1,212 @@
/***************************************************************************
smb4kbookmark.h - A bookmark container.
-------------------
begin : Feb 04 2004
copyright : (C) 2004 by Franck Babin
(C) 2005-2007 by Alexander Reinholdt
email : babinfranck@yahoo.ca
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 *
***************************************************************************/
#ifndef SMB4KBOOKMARK_H
#define SMB4KBOOKMARK_H
// Qt includes
#include <qstring.h>
// forward declarations
class Smb4KShareItem;
/**
* This class is a container for a set bookmark on a samba share
*/
class Smb4KBookmark
{
public:
/**
* The constructor.
*
* @param hostname The host name.
*
* @param sharename The share name.
*
* @param workgroup The workgroup/domain where the share is located.
*
* @param ip The IP address of the host
*
* @param type The type of the share, i.e. "disk" or "printer".
*
* @param label An alternative label to the share name.
*/
Smb4KBookmark( const QString &hostname,
const QString &sharename,
const QString &workgroup,
const QString &ip,
const QString &type,
const QString &label = QString::null );
/**
* An alternative constructor.
*
* @param item The Smb4KShareItem for which a bookmark should be
* created.
*
* @param ip The IP address of the host
*
* @param label An alternative label to the share name.
*/
Smb4KBookmark( Smb4KShareItem *item,
const QString &ip,
const QString &label = QString::null );
/**
* The empty constructor.
*/
Smb4KBookmark() {}
/**
* The destructor.
*/
~Smb4KBookmark();
/**
* This function returns the share name.
*
* @returns The share name
*/
const QString &share() const { return m_share; };
/**
* This function returns the workgroup/domain the share is located in.
*
* @returns The workgroup
*/
const QString &workgroup() const { return m_workgroup; }
/**
* This function returns the IP address of the host that carries the
* share.
*
* @returns The IP address
*/
const QString &ip() const { return m_ip; }
/**
* This function returns the type of the share, i.e. either "Disk" or
* "Printer"/"Print" and "IPC".
*
* @returns The type of the share
*/
const QString &type() const { return m_type; }
/**
* This function sets the share name of the bookmark. It is normally not
* necessary to use it, because all data should be passed to the constructor.
* In case of homes shares, however, this function is useful.
*
* @param name The share name
*/
void setShareName( const QString &name );
/**
* This function returns the bookmark name.
*
* @returns The name of the bookmark
*/
const QString &bookmark() const { return m_bookmark; }
/**
* This function returns the host name.
*
* @returns The name of the host
*/
const QString &host() const { return m_host; }
/**
* This function sets the IP address.
*
* @param ip The IP address
*/
void setIP( const QString &ip );
/**
* Return the alternative bookmark label.
*
* @returns the label.
*/
const QString &label() const { return m_label; }
/**
* Sets the alternative bookmark label.
*
* @param text The new text for the label
*/
void setLabel( const QString &text );
private:
/**
* The host name.
*/
QString m_host;
/**
* The share name.
*/
QString m_share;
/**
* The workgroup
*/
QString m_workgroup;
/**
* The IP address
*/
QString m_ip;
/**
* The type of the share;
*/
QString m_type;
/**
* The bookmark string.
*/
QString m_bookmark;
/**
* The alternative label
*/
QString m_label;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const QString &ip );
};
#endif

@ -0,0 +1,342 @@
/***************************************************************************
smb4kbookmarkhandler - This class handles the bookmarks.
-------------------
begin : Fr Jan 9 2004
copyright : (C) 2004 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 *
***************************************************************************/
// Qt includes
#include <qdir.h>
#include <qfile.h>
// KDE includes
#include <kstandarddirs.h>
#include <kdebug.h>
#include <kapplication.h>
// system specific includes
#include <stdlib.h>
#include <math.h>
// application specific includes
#include "smb4kbookmarkhandler.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
#include "smb4kglobal.h"
#include "smb4knetworkitems.h"
#include "smb4kbookmark.h"
using namespace Smb4KGlobal;
Smb4KBookmarkHandler::Smb4KBookmarkHandler( QValueList<Smb4KHostItem *> *hosts,
QObject *parent, const char *name )
: QObject( parent, name ), m_hosts( hosts )
{
// First we need the directory.
KStandardDirs *stddir = new KStandardDirs();
QString dir = locateLocal( "data", "smb4k", KGlobal::instance() );
if ( !stddir->exists( dir ) )
{
stddir->makeDir( dir );
}
delete stddir;
loadBookmarks();
}
Smb4KBookmarkHandler::~Smb4KBookmarkHandler()
{
for ( QValueList<Smb4KBookmark *>::Iterator it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
delete *it;
}
m_bookmarks.clear();
// Do not delete m_hosts here, because it is either NULL
// or it is handled outside of this class.
}
void Smb4KBookmarkHandler::addBookmark( Smb4KBookmark *bookmark )
{
if ( !bookmark )
{
return;
}
if ( QString::compare( bookmark->type(), "Printer" ) == 0 )
{
Smb4KError::error( ERROR_BOOKMARK_PRINTER );
return;
}
if ( QString::compare( bookmark->share(), "homes" ) == 0 )
{
QString share = specifyUser( bookmark->host(), kapp->mainWidget() ? kapp->mainWidget() : 0, "SpecifyUser" );
bookmark->setShareName( share );
}
// Search for the bookmark:
Smb4KBookmark *result = findBookmarkByName( bookmark->bookmark() );
if ( result )
{
if ( QString::compare( result->workgroup().upper(), bookmark->workgroup().upper() ) == 0 )
{
// It's the same bookmark. We'll update it in a very
// brutal but efficient way:
m_bookmarks.remove( result );
if ( result )
{
delete result;
}
}
m_bookmarks.append( bookmark );
}
else
{
// The bookmark is new. Append it to the list:
m_bookmarks.append( bookmark );
}
writeBookmarkList( m_bookmarks );
}
void Smb4KBookmarkHandler::writeBookmarkList( const QValueList<Smb4KBookmark *> &list )
{
if ( list != m_bookmarks )
{
for ( QValueListIterator<Smb4KBookmark *> it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
delete *it;
}
m_bookmarks.clear();
m_bookmarks = list;
}
QFile file( locateLocal( "data", "smb4k/bookmarks", KGlobal::instance() ) );
if ( file.open( IO_WriteOnly ) )
{
QTextStream ts( &file );
ts.setEncoding( QTextStream::Locale );
int serial_number = 0;
for ( QValueListConstIterator<Smb4KBookmark *> it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
if ( !(*it)->label().isEmpty() )
{
Smb4KBookmark *result = findBookmarkByLabel( (*it)->label() );
if ( result &&
(QString::compare( result->bookmark().upper(), (*it)->bookmark().upper() ) != 0 ||
QString::compare( result->workgroup().upper(), (*it)->workgroup().upper() ) != 0) )
{
Smb4KError::information( INFO_BOOKMARK_LABEL_IN_USE, (*it)->label(), (*it)->bookmark() );
(*it)->setLabel( QString( "%1 (%2)" ).arg( (*it)->label() ).arg( serial_number++ ) );
}
}
ts << (*it)->host() << ","
<< (*it)->share() << ","
<< (*it)->workgroup() << ","
<< (*it)->ip() << ","
<< (*it)->label() << endl;
}
file.close();
}
else
{
Smb4KError::error( ERROR_WRITING_FILE, QDir::currentDirPath()+"/"+file.name() );
return;
}
emit bookmarksUpdated();
}
void Smb4KBookmarkHandler::loadBookmarks()
{
QFile file( locateLocal( "data", "smb4k/bookmarks", KGlobal::instance() ) );
QStringList contents;
if ( file.open( IO_ReadOnly ) )
{
QTextStream ts( &file );
ts.setEncoding( QTextStream::Locale );
contents = QStringList::split( '\n', ts.read(), false );
file.close();
for ( QStringList::ConstIterator it = contents.begin(); it != contents.end(); ++it )
{
if ( (*it).startsWith( "#" ) || (*it).startsWith( "[" ) ||
QString::compare( (*it).stripWhiteSpace(), QString::null ) == 0 )
{
continue;
}
else
{
// Load old bookmark entries (prior to version 0.7.0)
if ( ((*it).stripWhiteSpace())[0].isDigit() )
{
QString bookmark = (*it).section( "=", 1, -1 ).stripWhiteSpace();
m_bookmarks.append( new Smb4KBookmark( bookmark.section( "/", 2, 2 ).stripWhiteSpace(), bookmark.section( "/", 3, 3 ).stripWhiteSpace(), QString::null, QString::null, "Disk" ) );
}
else
{
QString host = (*it).section( ",", 0, 0 ).stripWhiteSpace();
QString share = (*it).section( ",", 1, 1 ).stripWhiteSpace();
QString workgroup = (*it).section( ",", 2, 2 ).stripWhiteSpace();
QString ip = (*it).section( ",", 3, 3 ).stripWhiteSpace();
QString label = (*it).section( ",", 4, 4 ).stripWhiteSpace();
m_bookmarks.append( new Smb4KBookmark( host, share, workgroup, ip, "Disk", label ) );
}
}
}
emit bookmarksUpdated();
}
else
{
if ( file.exists() )
{
Smb4KError::error( ERROR_READING_FILE, file.name() );
}
else
{
// Do nothing if the file does not exist.
}
}
}
Smb4KBookmark *Smb4KBookmarkHandler::findBookmarkByName( const QString &bookmark )
{
// Update the bookmarks:
update();
// Find the bookmark:
QValueListConstIterator<Smb4KBookmark *> it;
for ( it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
if ( QString::compare( (*it)->bookmark().upper(), bookmark.upper() ) == 0 )
{
break;
}
}
return it != m_bookmarks.end() ? *it : NULL;
}
Smb4KBookmark *Smb4KBookmarkHandler::findBookmarkByLabel( const QString &label )
{
// Update the bookmarks:
update();
// Find the bookmark:
QValueListConstIterator<Smb4KBookmark *> it;
for ( it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
if ( QString::compare( (*it)->label().upper(), label.upper() ) == 0 )
{
break;
}
}
return it != m_bookmarks.end() ? *it : NULL;
}
const QValueList<Smb4KBookmark *> &Smb4KBookmarkHandler::getBookmarks()
{
// Update the bookmarks:
update();
// Return the list of bookmarks:
return m_bookmarks;
}
void Smb4KBookmarkHandler::update()
{
// If the user didn't pass the global Smb4KHostItem list, we are not able
// to update the bookmarks:
if ( !m_hosts )
{
return;
}
// Search the list of hosts for new IP addresses:
for ( QValueList<Smb4KBookmark *>::Iterator it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it )
{
for ( QValueList<Smb4KHostItem *>::ConstIterator i = m_hosts->begin(); i != m_hosts->end(); ++i )
{
if ( QString::compare( (*it)->workgroup().lower(), (*i)->workgroup().lower() ) != 0 )
{
// Continue, if the workgroup is not the same:
continue;
}
else
{
if ( QString::compare( (*it)->host().lower(), (*i)->name().lower() ) != 0 )
{
// Continue if the host name is not the same:
continue;
}
else
{
// Set the IP address if it changed:
if ( !(*i)->ip().stripWhiteSpace().isEmpty() &&
QString::compare( (*it)->ip(), (*i)->ip() ) != 0 )
{
(*it)->setIP( (*i)->ip() );
}
break;
}
}
}
}
}
#include "smb4kbookmarkhandler.moc"

@ -0,0 +1,162 @@
/***************************************************************************
smb4kbookmarkhandler - This class handles the bookmarks.
-------------------
begin : Fr Jan 9 2004
copyright : (C) 2004 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 *
***************************************************************************/
#ifndef SMB4KBOOKMARKHANDLER_H
#define SMB4KBOOKMARKHANDLER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qvaluelist.h>
// forward declarations
class Smb4KHostItem;
class Smb4KBookmark;
/**
* This class belongs the to core classes of Smb4K and manages the
* bookmarks.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KBookmarkHandler : public QObject
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param hosts A list of Smb4KHostItem items. This should be used
* to give the bookmark handler the list of known hosts,
* so it is able to update the bookmarks if necessary.
* In case a NULL pointer is passed, the bookmarks won't
* be updated.
*
* @param parent The parent of this object
*
* @param name This object's name
*/
Smb4KBookmarkHandler( QValueList<Smb4KHostItem *> *hosts = 0,
QObject *parent = 0,
const char *name = 0 );
/**
* The destructor.
*/
~Smb4KBookmarkHandler();
/**
* This function writes a bookmark to the bookmark file.
*
* NOTE: This function is more or less a wrapper around the
* writeBookmarList() function.
*
* @param bookmark A bookmark that is to be written to
* the bookmark file
*/
void addBookmark( Smb4KBookmark *bookmark );
/**
* This function writes a new list of bookmarks. The old list will be
* deleted. It should be used, if you manipulated the list of bookmarks
* i. e. by a bookmark editor. When this function finishes, the
* bookmarksUpdated() signal will be emitted.
*
* @param list The (new) list of bookmarks that is to be written
* to the bookmark file
*/
void writeBookmarkList( const QValueList<Smb4KBookmark *> &list );
/**
* Get the list of bookmarks.
*
* @returns The current list of bookmarks stored in the
* bookmark file.
*/
const QValueList<Smb4KBookmark *> &getBookmarks();
/**
* This function searches for a bookmark using its name (//HOST/SHARE) and
* returns a pointer to it if it is present or NULL.
*
* @param bookmark The bookmark that is searched. The string you enter
* must consist of the host and the share: //HOST/SHARE.
*
* @returns The bookmark object that was searched for or NULL if it
* wasn't found.
*/
Smb4KBookmark *findBookmarkByName( const QString &bookmark );
/**
* This function searches for a bookmark using its label and returns a pointer
* to it if it is present or NULL.
*
* @param label The label that is searched.
*
* @returns The bookmark object that was searched for or NULL if it
* wasn't found.
*/
Smb4KBookmark *findBookmarkByLabel( const QString &label );
signals:
/**
* Signal emitted when the list of bookmarks has been updated.
*/
void bookmarksUpdated();
private:
/**
* The list of bookmarks.
*/
QValueList<Smb4KBookmark *> m_bookmarks;
/**
* This function loads the list of bookmarks from the bookmarks file.
* When it finishes, the bookmarksUpdated() signal is emitted. So, if you
* want to access the list of bookmarks immediately after they were read,
* connect a slot to that signal.
*/
void loadBookmarks();
/**
* This lis is a pointer to a global list of all known hosts. It
* is used to update the bookmarks.
*/
QValueList<Smb4KHostItem *> *m_hosts;
/**
* This function updates the data of the bookmarks, i.e. is searches for
* the host provided by m_hosts and sets the appropriate data, if
* necessary.
*/
void update();
};
#endif

@ -0,0 +1,955 @@
/***************************************************************************
smb4kcore - The main core class of Smb4K.
-------------------
begin : Do Apr 8 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qdir.h>
#include <qmap.h>
#include <qstringlist.h>
// KDE includes
#include <kdeversion.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kurl.h>
#include <krun.h>
#include <kapplication.h>
#include <kpassivepopup.h>
#include <kdebug.h>
#include <kstaticdeleter.h>
#include <dcopclient.h>
// system includes
#include <stdlib.h>
// application specific includes
#include "smb4kcore.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
#include "smb4kglobal.h"
#include "smb4knetworkitems.h"
#include "smb4kshare.h"
#include "smb4ksambaoptionshandler.h"
#include "smb4ksettings.h"
using namespace Smb4KGlobal;
Smb4KCore *Smb4KCore::m_self = 0;
static KStaticDeleter<Smb4KCore> staticSmb4KCoreDeleter;
Smb4KCore::Smb4KCore() : QObject()
{
// Set default values for settings that depend on the system
// Smb4K is running on:
setDefaultSettings();
// Search for the programs that are needed by Smb4K:
searchPrograms();
m_fileIO = new Smb4KFileIO( this, "CoreFileIO" );
m_scanner = new Smb4KScanner( &m_workgroups, &m_hosts, this, "CoreScanner" );
m_mounter = new Smb4KMounter( this, "CoreMounter" );
m_bookmarkHandler = new Smb4KBookmarkHandler( &m_hosts, this, "CoreBookmarkHandler" );
m_print = new Smb4KPrint( this, "CorePrinterHandler" );
m_synchronizer = new Smb4KSynchronizer( this, "CoreSynchronizer" );
m_previewer = new Smb4KPreviewer( this, "CorePreviewer" );
m_scanner_state = SCANNER_STOP;
m_mounter_state = MOUNTER_STOP;
m_print_state = PRINT_STOP;
m_syncer_state = SYNCHRONIZER_STOP;
m_previewer_state = PREVIEWER_STOP;
// Connections:
connect( m_scanner, SIGNAL( state( int ) ),
this, SLOT( slotSetScannerState( int ) ) );
connect( m_mounter, SIGNAL( state( int ) ),
this, SLOT( slotSetMounterState( int ) ) );
connect( m_print, SIGNAL( state( int ) ),
this, SLOT( slotSetPrinterHandlerState( int ) ) );
connect( m_synchronizer, SIGNAL( state( int ) ),
this, SLOT( slotSetSynchronizerState( int ) ) );
connect( m_previewer, SIGNAL( state( int ) ),
this, SLOT( slotSetSynchronizerState( int ) ) );
connect( kapp, SIGNAL( shutDown() ),
this, SLOT( slotShutdown() ) );
}
Smb4KCore::~Smb4KCore()
{
// Do not call abort() here. This will most likely lead
// to crashes.
// Clear the list of workgroups.
for ( QValueList<Smb4KWorkgroupItem *>::Iterator it = m_workgroups.begin(); it != m_workgroups.end(); ++it )
{
delete *it;
}
m_workgroups.clear();
// Clear the list of hosts.
for ( QValueList<Smb4KHostItem *>::Iterator it = m_hosts.begin(); it != m_hosts.end(); ++it )
{
delete *it;
}
m_hosts.clear();
if ( m_self == this )
{
staticSmb4KCoreDeleter.setObject( m_self, 0, false );
}
}
Smb4KCore *Smb4KCore::self()
{
if ( !m_self )
{
staticSmb4KCoreDeleter.setObject( m_self, new Smb4KCore() );
}
return m_self;
}
void Smb4KCore::init()
{
// Start the core.
m_scanner->init();
m_mounter->init();
}
/****************************************************************************
Returns a bool that tells the program whether a core process is running.
****************************************************************************/
bool Smb4KCore::isRunning()
{
if ( self()->m_scanner->isRunning() || self()->m_mounter->isRunning() ||
self()->m_print->isRunning() || self()->m_synchronizer->isRunning() ||
self()->m_previewer->isRunning() )
{
return true;
}
else
{
return false;
}
}
/****************************************************************************
Sets the current state of the core.
****************************************************************************/
void Smb4KCore::setCurrentState( int state )
{
if ( state != SCANNER_STOP && state != MOUNTER_STOP &&
state != PRINT_STOP && state != SYNCHRONIZER_STOP &&
state != PREVIEWER_STOP )
{
m_current_state = state;
}
else
{
if ( !m_scanner->isRunning() && !m_mounter->isRunning() &&
!m_print->isRunning() && !m_synchronizer->isRunning() &&
!m_previewer->isRunning() )
{
m_current_state = CORE_STOP;
}
else
{
if ( m_scanner->isRunning() )
{
m_current_state = m_scanner_state;
}
else if ( m_print->isRunning() )
{
m_current_state = m_print_state;
}
else if ( m_mounter->isRunning() )
{
m_current_state = m_mounter_state;
}
else if ( m_synchronizer->isRunning() )
{
m_current_state = m_syncer_state;
}
else if ( m_previewer->isRunning() )
{
m_current_state = m_previewer_state;
}
}
}
}
/****************************************************************************
Aborts any process of the core.
****************************************************************************/
void Smb4KCore::abort()
{
self()->m_scanner->abort();
self()->m_mounter->abort();
self()->m_print->abort();
self()->m_synchronizer->abort();
self()->m_previewer->abort();
}
/****************************************************************************
Opens the given URL.
****************************************************************************/
void Smb4KCore::open( Smb4KShare *share, int openWith )
{
if ( !share || share->isBroken() )
{
return;
}
#if KDE_VERSION_MAJOR == 3 && KDE_VERSION_MINOR <= 3 && KDE_VERSION_RELEASE <= 92
if ( QString::compare( share->filesystem(), "cifs" ) == 0 )
{
if( KMessageBox::warningContinueCancel( (QWidget *)this, i18n( "Up to KDE 3.3.x, KIO and Konqueror cannot handle CIFS shares. Konqueror will hang if you try to access it.\nDo you want to continue?" ) ) == KMessageBox::Cancel )
{
return;
}
}
#endif
switch ( openWith )
{
case Konqueror:
{
KURL url;
url.setPath( share->canonicalPath() );
(void) new KRun( url, 0, true, true );
break;
}
case Konsole:
{
if ( Smb4KSettings::konsole().isEmpty() )
{
Smb4KError::error( ERROR_COMMAND_NOT_FOUND, "konsole" );
}
else
{
KRun::runCommand( "konsole --workdir "+share->canonicalPath() );
}
break;
}
default:
{
break;
}
}
}
/****************************************************************************
Searches for the programs needed by Smb4K
****************************************************************************/
void Smb4KCore::searchPrograms()
{
// Remove the group "Programs" and reread the
// configuration:
Smb4KSettings::self()->config()->deleteGroup( "Programs" );
Smb4KSettings::self()->readConfig();
// List of paths that should be searched.
QStringList path_list = QStringList::split( ":", QString( "%1" ).arg( getenv( "PATH" ) ), false );
if ( path_list.find( "/sbin" ) == path_list.end() )
{
path_list << "/sbin";
}
if ( path_list.find( "/usr/sbin" ) == path_list.end() )
{
path_list << "/usr/sbin";
}
if ( path_list.find( "/usr/local/sbin" ) == path_list.end() )
{
path_list << "/usr/local/sbin";
}
// Put all programs that are needed by Smb4K
// into the map below:
QMap<QString /*name*/, bool /*located*/> program_list;
QMap<QString /*name*/, QString /*absolute path*/> program_paths;
// Mandatory programs:
program_list.insert( "grep", false );
program_list.insert( "awk", false );
program_list.insert( "sed", false );
program_list.insert( "xargs", false );
program_list.insert( "rmdir", false );
program_list.insert( "nmblookup", false );
program_list.insert( "smbclient", false );
program_list.insert( "smbspool", false );
program_list.insert( "net", false );
#ifndef __FreeBSD__
program_list.insert( "mount.cifs", false );
program_list.insert( "umount.cifs", false );
program_list.insert( "smbmount", false );
program_list.insert( "smbumount", false );
program_list.insert( "mount", false );
#else
program_list.insert( "mount_smbfs", false );
program_list.insert( "smbutil", false );
#endif
program_list.insert( "umount", false );
program_list.insert( "smb4k_mount", false );
program_list.insert( "smb4k_umount", false );
program_list.insert( "smb4k_kill", false );
program_list.insert( "smb4k_cat", false );
program_list.insert( "smb4k_mv", false );
// Optional programs
program_list.insert( "super", false );
program_list.insert( "sudo", false );
program_list.insert( "dvips", false );
program_list.insert( "enscript", false );
program_list.insert( "rsync", false );
program_list.insert( "konsole", false );
for ( QStringList::ConstIterator it = path_list.begin(); it != path_list.end(); ++it )
{
QDir::setCurrent( *it );
for ( QMap<QString, bool>::Iterator p = program_list.begin(); p != program_list.end(); ++p )
{
if ( p.data() == false ) // not located yet
{
if ( QFile::exists( p.key() ) )
{
program_paths.insert( p.key(), QDir::currentDirPath()+QDir::separator()+p.key() );
program_list[ p.key() ] = true;
}
else
{
continue;
}
}
else
{
continue;
}
}
}
// Find out if Smb4K is to be starting up at all:
QStringList missing;
if ( !program_list["grep"] )
{
missing.append( "grep" );
}
else
{
Smb4KSettings::self()->grepItem()->setDefaultValue( program_paths["grep"] );
if ( Smb4KSettings::grep().isEmpty() )
{
Smb4KSettings::self()->grepItem()->setDefault();
}
}
if ( !program_list["awk"] )
{
missing.append( "awk" );
}
else
{
Smb4KSettings::self()->awkItem()->setDefaultValue( program_paths["awk"] );
if ( Smb4KSettings::awk().isEmpty() )
{
Smb4KSettings::self()->awkItem()->setDefault();
}
}
if ( !program_list["sed"] )
{
missing.append( "sed" );
}
else
{
Smb4KSettings::self()->sedItem()->setDefaultValue( program_paths["sed"] );
if ( Smb4KSettings::sed().isEmpty() )
{
Smb4KSettings::self()->sedItem()->setDefault();
}
}
if ( !program_list["xargs"] )
{
missing.append( "xargs" );
}
else
{
Smb4KSettings::self()->xargsItem()->setDefaultValue( program_paths["xargs"] );
if ( Smb4KSettings::xargs().isEmpty() )
{
Smb4KSettings::self()->xargsItem()->setDefault();
}
}
if ( !program_list["rmdir"] )
{
missing.append( "rmdir" );
}
else
{
Smb4KSettings::self()->rmdirItem()->setDefaultValue( program_paths["rmdir"] );
if ( Smb4KSettings::rmdir().isEmpty() )
{
Smb4KSettings::self()->rmdirItem()->setDefault();
}
}
if ( !program_list["nmblookup"] )
{
missing.append( "nmblookup" );
}
else
{
Smb4KSettings::self()->nmblookupItem()->setDefaultValue( program_paths["nmblookup"] );
if ( Smb4KSettings::nmblookup().isEmpty() )
{
Smb4KSettings::self()->nmblookupItem()->setDefault();
}
}
if ( !program_list["smbclient"] )
{
missing.append( "smbclient" );
}
else
{
Smb4KSettings::self()->smbclientItem()->setDefaultValue( program_paths["smbclient"] );
if ( Smb4KSettings::smbclient().isEmpty() )
{
Smb4KSettings::self()->smbclientItem()->setDefault();
}
}
if ( !program_list["smbspool"] )
{
missing.append( "smbspool" );
}
else
{
Smb4KSettings::self()->smbspoolItem()->setDefaultValue( program_paths["smbspool"] );
if ( Smb4KSettings::smbspool().isEmpty() )
{
Smb4KSettings::self()->smbspoolItem()->setDefault();
}
}
if ( !program_list["net"] )
{
missing.append( "net" );
}
else
{
Smb4KSettings::self()->netItem()->setDefaultValue( program_paths["net"] );
if ( Smb4KSettings::net().isEmpty() )
{
Smb4KSettings::self()->netItem()->setDefault();
}
}
#ifndef __FreeBSD__
if ( !program_list["mount.cifs"] && !program_list["smbmount"] )
{
missing.append( "mount.cifs & smbmount" );
}
else
{
// One of the two programs is at least present, so we can do
// it like this:
QString filesystem;
if ( program_list["mount.cifs"] )
{
Smb4KSettings::self()->mount_cifsItem()->setDefaultValue( program_paths["mount.cifs"] );
if ( Smb4KSettings::mount_cifs().isEmpty() )
{
Smb4KSettings::self()->mount_cifsItem()->setDefault();
}
}
else
{
Smb4KSettings::setFilesystem( Smb4KSettings::EnumFilesystem::SMBFS );
}
if ( program_list["smbmount"] )
{
Smb4KSettings::self()->smbmountItem()->setDefaultValue( program_paths["smbmount"] );
if ( Smb4KSettings::smbmount().isEmpty() )
{
Smb4KSettings::self()->smbmountItem()->setDefault();
}
}
else
{
Smb4KSettings::setFilesystem( Smb4KSettings::EnumFilesystem::CIFS );
}
}
if ( !program_list["umount.cifs"] && !program_list["smbumount"] )
{
missing.append( "umount.cifs & smbumount" );
}
else
{
// One of the two programs is at least present, so we can do
// it like this:
QString filesystem;
if ( program_list["umount.cifs"] )
{
Smb4KSettings::self()->umount_cifsItem()->setDefaultValue( program_paths["umount.cifs"] );
if ( Smb4KSettings::umount_cifs().isEmpty() )
{
Smb4KSettings::self()->umount_cifsItem()->setDefault();
}
}
else
{
Smb4KSettings::setFilesystem( Smb4KSettings::EnumFilesystem::SMBFS );
}
if ( program_list["smbumount"] )
{
Smb4KSettings::self()->smbumountItem()->setDefaultValue( program_paths["smbumount"] );
if ( Smb4KSettings::smbumount().isEmpty() )
{
Smb4KSettings::self()->smbumountItem()->setDefault();
}
}
else
{
Smb4KSettings::setFilesystem( Smb4KSettings::EnumFilesystem::CIFS );
}
}
if ( !program_list["mount"] )
{
missing.append( "mount" );
}
else
{
Smb4KSettings::self()->mountItem()->setDefaultValue( program_paths["mount"] );
if ( Smb4KSettings::mount().isEmpty() )
{
Smb4KSettings::self()->mountItem()->setDefault();
}
}
#else
if ( !program_list["mount_smbfs"] )
{
missing.append( "mount_smbfs" );
}
else
{
Smb4KSettings::self()->mount_smbfsItem()->setDefaultValue( program_paths["mount_smbfs"] );
if ( Smb4KSettings::mount_smbfs().isEmpty() )
{
Smb4KSettings::self()->mount_smbfsItem()->setDefault();
}
}
if ( !program_list["smbutil"] )
{
missing.append( "smbutil" );
}
else
{
Smb4KSettings::self()->smbutilItem()->setDefaultValue( program_paths["smbutil"] );
if ( Smb4KSettings::smbutil().isEmpty() )
{
Smb4KSettings::self()->smbutilItem()->setDefault();
}
}
#endif
if ( !program_list["umount"] )
{
missing.append( "umount" );
}
else
{
Smb4KSettings::self()->umountItem()->setDefaultValue( program_paths["umount"] );
if ( Smb4KSettings::umount().isEmpty() )
{
Smb4KSettings::self()->umountItem()->setDefault();
}
}
if ( !program_list["smb4k_mount"] )
{
missing.append( "smb4k_mount" );
}
else
{
Smb4KSettings::self()->smb4k_mountItem()->setDefaultValue( program_paths["smb4k_mount"] );
if ( Smb4KSettings::smb4k_mount().isEmpty() )
{
Smb4KSettings::self()->smb4k_mountItem()->setDefault();
}
}
if ( !program_list["smb4k_umount"] )
{
missing.append( "smb4k_umount" );
}
else
{
Smb4KSettings::self()->smb4k_umountItem()->setDefaultValue( program_paths["smb4k_umount"] );
if ( Smb4KSettings::smb4k_umount().isEmpty() )
{
Smb4KSettings::self()->smb4k_umountItem()->setDefault();
}
}
if ( !program_list["smb4k_kill"] )
{
missing.append( "smb4k_kill" );
}
else
{
Smb4KSettings::self()->smb4k_killItem()->setDefaultValue( program_paths["smb4k_kill"] );
if ( Smb4KSettings::smb4k_kill().isEmpty() )
{
Smb4KSettings::self()->smb4k_killItem()->setDefault();
}
}
if ( !program_list["smb4k_cat"] )
{
missing.append( "smb4k_cat" );
}
else
{
Smb4KSettings::self()->smb4k_catItem()->setDefaultValue( program_paths["smb4k_cat"] );
if ( Smb4KSettings::smb4k_cat().isEmpty() )
{
Smb4KSettings::self()->smb4k_catItem()->setDefault();
}
}
if ( !program_list["smb4k_mv"] )
{
missing.append( "smb4k_mv" );
}
else
{
Smb4KSettings::self()->smb4k_mvItem()->setDefaultValue( program_paths["smb4k_mv"] );
if ( Smb4KSettings::smb4k_mv().isEmpty() )
{
Smb4KSettings::self()->smb4k_mvItem()->setDefault();
}
}
if ( !missing.isEmpty() )
{
// Error out if one of the mandatory programs is
// missing:
Smb4KError::error( ERROR_MISSING_PROGRAMS, missing.join( ", " ) );
exit( EXIT_FAILURE );
}
else
{
// Check for the optional programs:
if ( !program_list["super"] )
{
if ( (Smb4KSettings::useForceUnmount() ||
Smb4KSettings::alwaysUseSuperUser()) &&
Smb4KSettings::superUserProgram() ==
Smb4KSettings::EnumSuperUserProgram::Super )
{
Smb4KError::information( INFO_DISABLE_SUID_FEATURE, "super" );
// Reset the super user settings:
Smb4KSettings::self()->useForceUnmountItem()->setDefault();
Smb4KSettings::self()->alwaysUseSuperUserItem()->setDefault();
}
else
{
// Do nothing
}
}
else
{
Smb4KSettings::self()->superItem()->setDefaultValue( program_paths["super"] );
if ( Smb4KSettings::super().isEmpty() )
{
Smb4KSettings::self()->superItem()->setDefault();
}
}
if ( !program_list["sudo"] )
{
if ( (Smb4KSettings::useForceUnmount() ||
Smb4KSettings::alwaysUseSuperUser()) &&
Smb4KSettings::superUserProgram() ==
Smb4KSettings::EnumSuperUserProgram::Super )
{
Smb4KError::information( INFO_DISABLE_SUID_FEATURE, "sudo" );
// Reset the super user settings:
Smb4KSettings::self()->useForceUnmountItem()->setDefault();
Smb4KSettings::self()->alwaysUseSuperUserItem()->setDefault();
}
else
{
// Do nothing
}
}
else
{
Smb4KSettings::self()->sudoItem()->setDefaultValue( program_paths["sudo"] );
if ( Smb4KSettings::sudo().isEmpty() )
{
Smb4KSettings::self()->sudoItem()->setDefault();
}
}
if ( program_list["dvips"] )
{
Smb4KSettings::self()->dvipsItem()->setDefaultValue( program_paths["dvips"] );
if ( Smb4KSettings::dvips().isEmpty() )
{
Smb4KSettings::self()->dvipsItem()->setDefault();
}
}
if ( program_list["enscript"] )
{
Smb4KSettings::self()->enscriptItem()->setDefaultValue( program_paths["enscript"] );
if ( Smb4KSettings::enscript().isEmpty() )
{
Smb4KSettings::self()->enscriptItem()->setDefault();
}
}
if ( program_list["rsync"] )
{
Smb4KSettings::self()->rsyncItem()->setDefaultValue( program_paths["rsync"] );
if ( Smb4KSettings::rsync().isEmpty() )
{
Smb4KSettings::self()->rsyncItem()->setDefault();
}
}
if ( program_list["konsole"] )
{
Smb4KSettings::self()->konsoleItem()->setDefaultValue( program_paths["konsole"] );
if ( Smb4KSettings::konsole().isEmpty() )
{
Smb4KSettings::self()->konsoleItem()->setDefault();
}
}
// Write the configuration to disk:
Smb4KSettings::writeConfig();
}
}
void Smb4KCore::setDefaultSettings()
{
// Samba options that have to be dynamically imported from smb.conf:
QMap<QString, QString> opts = optionsHandler()->globalSambaOptions();
if ( !opts["netbios name"].isEmpty() )
{
Smb4KSettings::self()->netBIOSNameItem()->setDefaultValue( opts["netbios name"] );
if ( Smb4KSettings::netBIOSName().isEmpty() )
{
Smb4KSettings::self()->netBIOSNameItem()->setDefault();
}
}
if ( !opts["workgroup"].isEmpty() )
{
Smb4KSettings::self()->domainNameItem()->setDefaultValue( opts["workgroup"] );
if ( Smb4KSettings::domainName().isEmpty() )
{
Smb4KSettings::self()->domainNameItem()->setDefault();
}
}
if ( !opts["socket options"].isEmpty() )
{
Smb4KSettings::self()->socketOptionsItem()->setDefaultValue( opts["socket options"] );
if ( Smb4KSettings::socketOptions().isEmpty() )
{
Smb4KSettings::self()->socketOptionsItem()->setDefault();
}
}
if ( !opts["netbios scope"].isEmpty() )
{
Smb4KSettings::self()->netBIOSScopeItem()->setDefaultValue( opts["netbios scope"] );
if ( Smb4KSettings::netBIOSScope().isEmpty() )
{
Smb4KSettings::self()->netBIOSScopeItem()->setDefault();
}
}
if ( !opts["name resolve order"].isEmpty() )
{
Smb4KSettings::self()->nameResolveOrderItem()->setDefaultValue( opts["name resolve order"] );
if ( Smb4KSettings::nameResolveOrder().isEmpty() )
{
Smb4KSettings::self()->nameResolveOrderItem()->setDefault();
}
}
if ( !opts["interfaces"].isEmpty() )
{
Smb4KSettings::self()->broadcastAddressItem()->setDefaultValue( opts["interfaces"] );
if ( Smb4KSettings::broadcastAddress().isEmpty() )
{
Smb4KSettings::self()->broadcastAddressItem()->setDefault();
}
}
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KCore::slotSetScannerState( int state )
{
m_scanner_state = state;
setCurrentState( state );
emit runStateChanged();
}
void Smb4KCore::slotSetMounterState( int state )
{
m_mounter_state = state;
setCurrentState( state );
emit runStateChanged();
}
void Smb4KCore::slotSetPrinterHandlerState( int state )
{
m_print_state = state;
setCurrentState( state );
emit runStateChanged();
}
void Smb4KCore::slotSetSynchronizerState( int state )
{
m_syncer_state = state;
setCurrentState( state );
emit runStateChanged();
}
void Smb4KCore::slotSetPreviewerState( int state )
{
m_previewer_state = state;
setCurrentState( state );
emit runStateChanged();
}
void Smb4KCore::slotShutdown()
{
Smb4KSettings::writeConfig();
}
#include "smb4kcore.moc"

@ -0,0 +1,354 @@
/***************************************************************************
smb4kcore - The main core class of Smb4K.
-------------------
begin : Do Apr 8 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KCORE_H
#define SMB4KCORE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qmap.h>
#include <qtimer.h>
#include <qvaluelist.h>
// application specific includes
#include "smb4kscanner.h"
#include "smb4kmounter.h"
#include "smb4kfileio.h"
#include "smb4kbookmarkhandler.h"
#include "smb4kprint.h"
#include "smb4ksynchronizer.h"
#include "smb4kpreviewer.h"
// forward declarations
class Smb4KWorkgroupItem;
class Smb4KHostItem;
class Smb4KShare;
/**
* This is the top-level core class. It inherits most of the core classes.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KCore : public QObject
{
Q_OBJECT
public:
/**
* Returns a static pointer to this class.
*/
static Smb4KCore *self();
/**
* The destructor.
*/
~Smb4KCore();
/**
* This function registers with the DCOP server and starts the core.
* It initializes the scanning of the network, the remounting of
* recently used shares, etc. Use this, if you want to take advantage
* of the automatic features of Smb4K's core.
*/
void init();
/**
* Returns the state the scanner is in.
*/
static int scannerState() { return self()->m_scanner_state; }
/**
* Returns TRUE, if the scanner is running, otherwise FALSE.
*/
static bool scannerIsRunning() { return self()->m_scanner->isRunning(); }
/**
* Returns the state the mounter is in.
*/
static int mounterState() { return self()->m_mounter_state; }
/**
* Returns TRUE, if the mounter is running, otherwise FALSE.
*/
static bool mounterIsRunning() { return self()->m_mounter->isRunning(); }
/**
* Returns the state the print object is in.
*/
static int printState() { return self()->m_print_state; }
/**
* Returns TRUE, if the print object is running, otherwise FALSE.
*/
static bool printIsRunning() { return self()->m_print->isRunning(); }
/**
* Returns the state the synchronizer is in.
*/
static int synchronizerState() { return self()->m_syncer_state; }
/**
* Returns TRUE, if the synchronizer is running, otherwise FALSE.
*/
static bool synchronizerIsRunning() { return self()->m_synchronizer->isRunning(); }
/**
* Returns TRUE if one of the core classes is doing something.
*/
static bool isRunning();
/**
* Returns the current state the core is in.
*/
static int currentState() { return self()->m_current_state; }
/**
* Returns a pointer to the scanner object.
*/
static Smb4KScanner *scanner() { return self()->m_scanner; }
/**
* Returns a pointer to the mounter object.
*/
static Smb4KMounter *mounter() { return self()->m_mounter; }
/**
* Returns a pointer to the bookmark handler object.
*/
static Smb4KBookmarkHandler *bookmarkHandler() { return self()->m_bookmarkHandler; }
/**
* Returns a pointer to the file IO object.
*/
static Smb4KFileIO *fileIO() { return self()->m_fileIO; }
/**
* Returns a pointer to the printer handler object.
*/
static Smb4KPrint *print() { return self()->m_print; }
/**
* Returns a pointer to the synchronizer object.
*/
static Smb4KSynchronizer *synchronizer() { return self()->m_synchronizer; }
/**
* Returns a pointer to the previewer object.
*/
static Smb4KPreviewer *previewer() { return self()->m_previewer; }
/**
* Aborts any action of the core.
*/
static void abort();
/**
* This enumeration determines with which application the mount point
* of the current mounted share is to be opened.
*/
enum OpenWith { Konqueror, Konsole };
/**
* Opens the mount point of a share. This function is used to run the file manager.
*
* @param share The share to be opened.
*
* @param openWith Integer of type Smb4KCore::OpenWith. Determines with which
* application the share should be opened.
*/
static void open( Smb4KShare *share, int openWith = Konqueror );
signals:
/**
* This signal is emitted, if one of the core objects
* starts or stops running.
*/
void runStateChanged();
protected:
/**
* The constructor
*/
Smb4KCore();
/**
* A static pointer to this class
*/
static Smb4KCore *m_self;
protected slots:
/**
* This slot sets the run state of the scanner.
*
* @param state The run state the scanner is in. For definition of the
* run states see smb4kdefs.h header file.
*/
void slotSetScannerState( int state );
/**
* This slot sets the run state of the mounter.
*
* @param state The run state the mounter is in. For definition of the
* run states see smb4kdefs.h header file.
*/
void slotSetMounterState( int state );
/**
* This slot sets the run state of the synchronizer.
*
* @param state The run state the synchronizer is in. For definition of the
* run states see smb4kdefs.h header file.
*/
void slotSetSynchronizerState( int state );
/**
* This slot sets the run state of the print handler.
*
* @param state The run state the print handler is in. For definition of the
* run states see smb4kdefs.h header file.
*/
void slotSetPrinterHandlerState( int state );
/**
* This slot sets the run state for the previewer.
*
* @param state The state the previewer is in. For definition of the
* run states see smb4kdefs.h header file.
*/
void slotSetPreviewerState( int state );
/**
* This slot is connected to the KApplication::shutDown() signal. It is invoked
* when the application is shut down by the KDE logout or by pressing CTRL+Q, etc.
*/
void slotShutdown();
private:
/**
* The scanner object.
*/
Smb4KScanner *m_scanner;
/**
* The mounter object.
*/
Smb4KMounter *m_mounter;
/**
* The bookmark handler object.
*/
Smb4KBookmarkHandler *m_bookmarkHandler;
/**
* The FileIO object.
*/
Smb4KFileIO *m_fileIO;
/**
* The printer handler object.
*/
Smb4KPrint *m_print;
/**
* The synchronizer object.
*/
Smb4KSynchronizer *m_synchronizer;
/**
* The previewer object.
*/
Smb4KPreviewer *m_previewer;
/**
* The state the sanner is in.
*/
int m_scanner_state;
/**
* The state the mounter is in.
*/
int m_mounter_state;
/**
* Holds the current state.
*/
int m_current_state;
/**
* The state the printer handler is in.
*/
int m_print_state;
/**
* The state the synchronizer is in.
*/
int m_syncer_state;
/**
* The state of the previewer is in.
*/
int m_previewer_state;
/**
* This function is used to set the current state of the core.
*
* @param state One of the states defined in smb4kdefs.h
*/
void setCurrentState( int state );
/**
* Searches for the needed programs and emits an error
* if mandatory ones are missing.
*/
void searchPrograms();
/**
* This is the list of workgroups known to Smb4K. It is filled by
* the scanner and may be used by all other classes that are invoked
* by Smb4KCore.
*/
QValueList<Smb4KWorkgroupItem *> m_workgroups;
/**
* This is the list of remote hosts known to Smb4K. It is filled by
* the scanner and may be used by all other classes that are invoked
* by Smb4KCore.
*/
QValueList<Smb4KHostItem *> m_hosts;
/**
* Set default values for settings that depend on the system Smb4K is
* running on and that have to be set dynamically.
*/
void setDefaultSettings();
};
#endif

@ -0,0 +1,147 @@
/***************************************************************************
smb4kdefs.h - Definitions for Smb4K
-------------------
begin : Mo Mär 15 2004
copyright : (C) 2004 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 *
***************************************************************************/
#ifndef SMB4KDEFS_H
#define SMB4KDEFS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
//
// Run states
//
#define SCANNER_INIT 0
#define SCANNER_OPENING_WORKGROUP 1
#define SCANNER_OPENING_HOST 2
#define SCANNER_RETRIEVING_INFO 3
#define SCANNER_SEARCHING 4
#define SCANNER_RETRYING_OPENING_HOST 5
#define SCANNER_STOP 6
#define MOUNTER_MOUNTING 7
#define MOUNTER_UNMOUNTING 8
#define MOUNTER_STOP 9
#define PRINT_START 10
#define PRINT_STOP 11
#define SYNCHRONIZER_START 12
#define SYNCHRONIZER_STOP 13
#define PREVIEWER_START 14
#define PREVIEWER_STOP 15
#define CORE_STOP 16
//
// Error codes:
//
// (1) Network related errors.
#define ERROR_GETTING_BROWSELIST 100
#define ERROR_GETTING_MEMBERS 101
#define ERROR_GETTING_SHARES 102
#define ERROR_GETTING_PREVIEW 103
#define ERROR_NET_COMMAND 104
#define ERROR_IP_CANNOT_BE_USED 105
// (2) Errors involving mounting, unmounting
// and importing shares.
#define ERROR_MOUNTING_SHARE 106
#define ERROR_UNMOUNTING_SHARE 107
#define ERROR_UNMOUNTING_NOT_ALLOWED 108
#define ERROR_MOUNTPOINT_EMPTY 109
#define ERROR_IMPORTING_SHARES 110
// (3) Errors that are connected to printing
#define ERROR_PRINTING 111
// (4) Errors that are connected to
// synchronization
#define ERROR_SYNCHRONIZING 112
// (5) Errors that occur when handling
// bookmarks
#define ERROR_BOOKMARK_PRINTER 113
// (6) Errors that occur when handling
// authentication data
#define ERROR_OPENING_WALLET_FAILED 114
// (7) Errors that occur when handling files
// and directories.
#define ERROR_FILE_NOT_FOUND 115
#define ERROR_OPENING_FILE 116
#define ERROR_READING_FILE 117
#define ERROR_WRITING_FILE 118
#define ERROR_CLOSING_FILE 119
#define ERROR_GETTING_PERMISSIONS 120
#define ERROR_DIRECTORY_NOT_FOUND 121
#define ERROR_CREATING_TEMP_DIR 122
#define ERROR_CREATING_TEMP_FILE 123
#define ERROR_FILE_IS_IRREGULAR 124
#define ERROR_MKDIR_FAILED 125
// (8) Errors that occur when handling programs
#define ERROR_MISSING_PROGRAMS 126
#define ERROR_COMMAND_NOT_FOUND 127
// (9) Other errors
#define ERROR_UNKNOWN 128
#define ERROR_GETTING_HOSTNAME 129
#define ERROR_LOCKED 130
#define ERROR_FEATURE_NOT_ENABLED 131
#define ERROR_GETTING_GIDS 132
//
// Warning codes:
//
/* None defined yet. use 200 ff. for that */
//
// Information codes:
//
#define INFO_MIMETYPE_NOT_SUPPORTED 300
#define INFO_DISABLE_SUID_FEATURE 301
#define INFO_BOOKMARK_LABEL_IN_USE 302
//
// Event types
//
#define EVENT_LOAD_SETTINGS 100000
#define EVENT_SET_FOCUS 100001
#define EVENT_SCAN_NETWORK 100002
//
// Other definitions
//
#define TIMER_INTERVAL 25
#define THREAD_WAITING_TIME 100
#define TEMPPATHLEN 18
#endif

@ -0,0 +1,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 QString &text, const QString &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." ).arg( 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." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be mounted.\nRead the error message under \"Details\" to find out more." ).arg( 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." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The share \"%1\" could not be unmounted.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
}
break;
}
case ERROR_FILE_NOT_FOUND:
{
KMessageBox::error( 0, i18n( "The file \"%1\" could not be found." ).arg( text ) );
break;
}
case ERROR_READING_FILE:
{
if ( details.stripWhiteSpace().isEmpty() )
{
KMessageBox::error( 0, i18n( "The file \"%1\" could not be read." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be read.\nRead the error message under \"Details\" to find out more." ).arg( 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." ).arg( 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." ).arg( text.section( ":", 1, 1 ), text.section( ":", 0, 0 ) ) );
break;
}
case ERROR_MKDIR_FAILED:
{
KMessageBox::error( 0, i18n( "The directory \"%1\" could not be created." ).arg( text ) );
break;
}
case ERROR_WRITING_FILE:
{
KMessageBox::error( 0, i18n( "The file \"%1\" could not be written." ).arg( 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." ).arg( 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." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be printed.\nRead the error message under \"Details\" to find out more." ).arg( 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." ).arg( text ) );
}
else
{
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 );
}
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." ).arg( text ) );
}
else
{
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 );
}
break;
}
case ERROR_DIRECTORY_NOT_FOUND:
{
KMessageBox::error( 0, i18n( "The directory \"%1\" could not be found." ).arg( 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." ).arg( 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." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be opened.\nRead the error message under \"Details\" to find out more." ).arg( text ), details );
}
break;
}
case ERROR_CLOSING_FILE:
{
if ( details.stripWhiteSpace().isEmpty() )
{
KMessageBox::error( 0, i18n( "The file \"%1\" could not be closed." ).arg( text ) );
}
else
{
KMessageBox::detailedError( 0, i18n( "The file \"%1\" could not be closed.\nRead the error message under \"Details\" to find out more." ).arg( 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" ).arg( 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 QString &, const QString & )
{
switch ( code )
{
default:
{
return 0;
}
}
}
void Smb4KError::information( int code, const QString &text, const QString &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." ).arg( 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." ).arg( 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." ).arg( text, details ) );
break;
}
default:
{
break;
}
}
}
// No moc file needs to be included

@ -0,0 +1,92 @@
/***************************************************************************
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 *
***************************************************************************/
#ifndef SMB4KERROR_H
#define SMB4KERROR_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
class Smb4KError
{
public:
/**
* Show an error that occurred in the core.
*
* @param code The error code as defined in smb4kdefs.h
*
* @param text Short text which will be included in the message that's shown
* to the user. Normally, a file name or similar is entered here.
* May be left blank if you do not need to fill text into the error
* message. Please note, that this text is not used to show details.
*
* @param details The text passed here is used to show details. Please note, that
* it depends on the kind of error if it is indeed shown.
*/
static void error( int code,
const QString &text = QString::null,
const QString &details = QString::null );
/**
* Show a warning.
*
* @param code The code as defined in smb4kdefs.h
*
* @param text Short text which will be included in the message that's shown
* to the user. Normally, a file name or similar is entered here.
* May be left blank if you do not need to fill text into the error
* message. Please note, that this text is not used to show details.
*
* @param details The text passed here is used to show details. Please note, that
* it depends on the kind of error if it is indeed shown.
*
* @returns an integer value according to KMessageBox::ButtonCode or 0 if the warning code
* is unknown.
*/
static int warning( int code,
const QString &text = QString::null,
const QString &details = QString::null );
/**
* Show an information.
*
* @param code The code as defined in smb4kdefs.h
*
* @param text Short text which will be included in the message that's shown
* to the user. Normally, a file name or similar is entered here.
* May be left blank if you do not need to fill text into the error
* message. Please note, that this text is not used to show details.
*
* @param details The text passed here is used to show details. Please note, that
* it depends on the kind of error if it is indeed shown.
*/
static void information( int code,
const QString &text = QString::null,
const QString &details = QString::null );
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,246 @@
/***************************************************************************
smb4kfileio - Does file IO operations for Smb4K
-------------------
begin : Do Jan 1 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KFILEIO_H
#define SMB4KFILEIO_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstring.h>
#include <qcstring.h>
// KDE include
#include <kprocess.h>
/**
* This class belongs to the core classes of Smb4K. It handles IO
* operations that are performed on system configuration files.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KFileIO : public QObject
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent object of this class
*
* @param name The name of this class
*/
Smb4KFileIO( QObject *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KFileIO();
/**
* Enumeration that determines for which super user program we perform
* the current action.
*/
enum Operation { Insert, Remove, NoOperation };
/**
* This function writes changes to the sudoers configuration file.
*
* @param operation Defines whether entries should be inserted or if
* they should be removed. With Smb4KFileIO::NoOperation
* the function exits immediately and returns TRUE.
*
* @returns TRUE if the write process was successfully initiate and FALSE
* otherwise.
*
* @note You need to connect to the finished() and failed() signals to find
* out if the the write process finished successfully.
*
*/
bool writeSudoers( Smb4KFileIO::Operation operation );
/**
* This function writes changes to the super.tab configuration file.
*
* @param operation Defines whether entries should be inserted or if
* they should be removed. With Smb4KFileIO::NoOperation
* the function exits immediately and returns TRUE.
*
* @returns TRUE if the write process was successfully initiate and FALSE
* otherwise.
*
* @note You need to connect to the finished() and failed() signals to find
* out if the the write process finished successfully.
*
*/
bool writeSuperTab( Smb4KFileIO::Operation operation );
signals:
/**
* This signal is emitted when somthing went wrong with the writing to
* the system configuration files.
*/
void failed();
/**
* This signal is emitted when the writing to the system configuration
* files has finished. It is emitted in case the writing was successful
* as well as in case it wasn't.
*/
void finished();
protected slots:
/**
* This slot is invokes when the application is closed. It is connected
* to KApplication::shutDown().
*/
void slotShutdown();
/**
* This slot receives shell program output from Stderr.
*
* @param proc The KProcess object
*
* @param buf The buffer that holds the error output
*
* @param len The length of the buffer
*/
void slotReceivedStderr( KProcess *proc, char *buf, int len );
/**
* This slot receives shell program output from Stdout.
*
* @param proc The KProcess object
*
* @param buf The buffer that holds the output
*
* @param len The length of the buffer
*/
void slotReceivedStdout( KProcess *proc, char *buf, int len );
/**
* This slot is called, when the process exited.
*
* @param proc The KProcess object
*/
void slotProcessExited( KProcess *proc );
private:
/**
* This function creates a lock file in /tmp if it does not
* exist already. If the user is not allowed to write to the
* desired file a the moment, the user will be shown an error
* dialog and the function will return FALSE.
*
* Checks are performed to make sure it is save to write to an
* existing lock file using the system call lstat().
*
* @param filename The name of the file that is to be modified.
*
* @returns TRUE if the creation was successful and FALSE if
* something went wrong.
*/
bool createLockFile( const QString &filename );
/**
* This function removes the lock file or at least the
* entry within it.
*
* Checks are performed to make sure it is save to write to an
* existing lock file using the system call lstat().
*
* @param shutdown Should be set to FALSE if you do not want to have
* any error message shown. Otherwise you should set it
* to TRUE.
*
* @returns TRUE if the removal was successful and FALSE if
* something went wrong.
*/
bool removeLockFile( const bool error_message = true );
/**
* This function finds a file.
*
* @param filename The name of the file
*
* @returns the canonical path of the file or an empty string if it could not be
* found.
*/
const QCString findFile( const QString &filename );
/**
* Enumeration that is used to tell the process what has to be done.
*/
enum State { ReadSudoers, ReadSuperTab, WriteSudoers, WriteSuperTab, Idle };
/**
* This integer holds one of the entries of the enumeration above.
*/
State m_state;
/**
* This buffer holds the output that was received at Stdout.
*/
QString m_buffer;
/**
* Process the sudoers file.
*/
void processSudoers();
/**
* Process the sudoers file.
*/
void processSuperTab();
/**
* This is the absolute path of the lock file.
*/
QCString m_lock_file;
/**
* Which operation should be performed
*/
Operation m_operation;
/**
* The KProcess object
*/
KProcess *m_proc;
/**
* Tell if an error occurred.
*/
bool m_error_occurred;
};
#endif

@ -0,0 +1,78 @@
/***************************************************************************
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 <kconfig.h>
#include <kdebug.h>
// application specific includes
#include "smb4kglobal.h"
#include "smb4kglobal_p.h"
#include "smb4kdefs.h"
static Smb4KGlobalPrivate p;
QTimer *Smb4KGlobal::timer()
{
return p.timer();
}
const int Smb4KGlobal::timerInterval()
{
return TIMER_INTERVAL;
}
const QString Smb4KGlobal::specifyUser( const QString &host, QWidget *parent, const char *name )
{
return p.homesHandler()->specifyUser( host, parent, name );
}
Smb4KPasswordHandler *Smb4KGlobal::passwordHandler()
{
return p.passwordHandler();
}
Smb4KSambaOptionsHandler *Smb4KGlobal::optionsHandler()
{
return p.optionsHandler();
}
const QString &Smb4KGlobal::tempDir()
{
return p.tempDir();
}
const QStringList Smb4KGlobal::homesUsers( const QString &host )
{
return p.homesUsers( host );
}

@ -0,0 +1,115 @@
/***************************************************************************
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KGLOBAL_H
#define SMB4KGLOBAL_H
#include <qstring.h>
#include <qtimer.h>
#include <kconfig.h>
// forward declarations:
class Smb4KPasswordHandler;
class Smb4KSambaOptionsHandler;
class Smb4KHomesSharesHandler;
/**
* This is the global namespace for the core classes of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
namespace Smb4KGlobal
{
/**
* This returns the pointer to the global timer for the application.
* WARNING: Du *NOT* stop this timer anywhere in the program or all
* actions that need a timer are stopped all over the application!
*
* @returns A pointer to the global timer.
*/
QTimer *timer() KDE_DEPRECATED;
/**
* This function returns the interval of the timer.
*
* @returns The interval of the timer in msec.
*/
const int timerInterval();
/**
* This function will open a dialog where the user has to define a
* user name to access a 'homes' share. Besides returning this name,
* this function will also store the name in the configuration file.
*
* @param host The host where the homes share is located
*
* @param parent The parent widget
*
* @param name The name of this dialog
*
* @returns A user name
*/
const QString specifyUser( const QString &host, QWidget *parent = 0, const char *name = 0 );
/**
* This function returns the password handler.
*
* @returns a pointer to the global password handler object.
*/
Smb4KPasswordHandler *passwordHandler();
/**
* This function returns a pointer to the global Smb4KOptionsHandler object.
* You need to use it if you want to retrieve (a) the custom options defined for
* a share, (b) the argument strings for the 'net', 'smbclient', or 'nmblookup'
* command, or (c) the options in the global section of the smb.conf configuration
* file.
*
* @returns a pointer to the global options handler object.
*/
Smb4KSambaOptionsHandler *optionsHandler();
/**
* This function creates a temporary directory and returns its name. If it already
* exists, only the name will be returned. If an failure occurrs, an error message
* will be shown and an empty string is returned.
*
* @returns the name of the temporary directory.
*/
const QString &tempDir();
/**
* Get the user names that are defined for a homes share.
*
* @param host The name of the host where the 'homes' share is located.
*
* @returns the list of user names for this homes share.
*/
const QStringList homesUsers( const QString &host );
};
#endif

@ -0,0 +1,123 @@
/***************************************************************************
smb4kglobal_p - This is the private helper class of the Smb4KGlobal
namespace.
-------------------
begin : Di Jul 24 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// system includes
#include <errno.h>
#include <stdlib.h>
// application specific includes
#include "smb4kglobal_p.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
Smb4KGlobalPrivate::Smb4KGlobalPrivate()
{
m_timer = new QTimer();
m_timer->start( TIMER_INTERVAL, false );
// Do NOT initialize these classes here; you'll
// get crashes.
m_passwd_handler = NULL;
m_options_handler = NULL;
m_homes_handler = NULL;
m_temp_dir = QString::null;
}
Smb4KGlobalPrivate::~Smb4KGlobalPrivate()
{
rmdir( m_temp_dir.local8Bit() );
delete m_timer;
delete m_passwd_handler;
delete m_options_handler;
delete m_homes_handler;
}
QTimer *Smb4KGlobalPrivate::timer()
{
return m_timer;
}
Smb4KHomesSharesHandler *Smb4KGlobalPrivate::homesHandler()
{
return m_homes_handler ? m_homes_handler :
(m_homes_handler = new Smb4KHomesSharesHandler());
}
Smb4KPasswordHandler *Smb4KGlobalPrivate::passwordHandler()
{
#ifndef __FreeBSD__
return m_passwd_handler ? m_passwd_handler :
(m_passwd_handler = new Smb4KPasswordHandler( homesHandler() ));
#else
return m_passwd_handler ? m_passwd_handler :
(m_passwd_handler = new Smb4KPasswordHandler( homesHandler(), optionsHandler() ));
#endif
}
Smb4KSambaOptionsHandler *Smb4KGlobalPrivate::optionsHandler()
{
return m_options_handler ? m_options_handler :
(m_options_handler = new Smb4KSambaOptionsHandler());
}
const QString &Smb4KGlobalPrivate::tempDir()
{
if ( m_temp_dir.isEmpty() )
{
char tmpd_name[] = "/tmp/smb4k.XXXXXX";
if ( mkdtemp( tmpd_name ) == NULL )
{
Smb4KError::error( ERROR_CREATING_TEMP_DIR, tmpd_name, strerror( errno ) );
return QString::null;
}
m_temp_dir = QString( tmpd_name );
}
return m_temp_dir;
}
const QStringList Smb4KGlobalPrivate::homesUsers( const QString &host )
{
if ( !m_homes_handler )
{
m_homes_handler = new Smb4KHomesSharesHandler();
}
return m_homes_handler->homesUsers( host );
}

@ -0,0 +1,102 @@
/***************************************************************************
smb4kglobal_p - This is the private helper class of the Smb4KGlobal
namespace.
-------------------
begin : Di Jul 24 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KGLOBAL_P_H
#define SMB4KGLOBAL_P_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qtimer.h>
// KDE includes
#include <kconfig.h>
// application specific includes
#include "smb4kpasswordhandler.h"
#include "smb4ksambaoptionshandler.h"
#include "smb4khomesshareshandler.h"
/**
* This class is a private helper for the Smb4KGlobal namespace.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KGlobalPrivate
{
public:
/**
* Constructor
*/
Smb4KGlobalPrivate();
/**
* Destructor
*/
~Smb4KGlobalPrivate();
/**
* Returns a pointer to the global timer
*/
QTimer *timer();
/**
* Returns the handler for homes shares
*/
Smb4KHomesSharesHandler *homesHandler();
/**
* Returns a pointer to the global password handler object
*/
Smb4KPasswordHandler *passwordHandler();
/**
* Returns a pointer to the global Samba options handler
*/
Smb4KSambaOptionsHandler *optionsHandler();
/**
* Returns the name of the temporary directory.
*/
const QString &tempDir();
/**
* Return the user names defined for a certain homes share
*/
const QStringList homesUsers( const QString &host );
private:
QTimer *m_timer;
Smb4KPasswordHandler *m_passwd_handler;
Smb4KSambaOptionsHandler *m_options_handler;
Smb4KHomesSharesHandler *m_homes_handler;
QString m_temp_dir;
};
#endif

@ -0,0 +1,361 @@
/***************************************************************************
smb4khomesshareshandler - This class handles the homes shares.
-------------------
begin : Do Aug 10 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 *
***************************************************************************/
// Qt includes
#include <qmap.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qfile.h>
// KDE includes
#include <kdebug.h>
#include <kstandarddirs.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kcombobox.h>
// application specific includes
#include "smb4khomesshareshandler.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
Smb4KHomesSharesHandler::Smb4KHomesSharesHandler( QObject *parent, const char *name )
: QObject( parent, name )
{
// First we need the directory.
KStandardDirs *stddir = new KStandardDirs();
QString dir = locateLocal( "data", "smb4k", KGlobal::instance() );
if ( !stddir->exists( dir ) )
{
stddir->makeDir( dir );
}
delete stddir;
m_dlg = NULL;
}
Smb4KHomesSharesHandler::~Smb4KHomesSharesHandler()
{
delete m_dlg;
}
const QString Smb4KHomesSharesHandler::specifyUser( const QString &host, QWidget *parent, const char *name )
{
QString username = QString::null;
m_dlg = new KDialogBase( KDialogBase::Plain, i18n( "Specify User" ), KDialogBase::User1|KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, parent, name, true, true );
m_dlg->setButtonGuiItem( KDialogBase::User1, KGuiItem( i18n( "Clear List" ), "editdelete", 0, 0 ) );
m_dlg->enableButton( KDialogBase::Ok, false );
m_dlg->enableButton( KDialogBase::User1, false );
// Set up the ask pass dialog.
QFrame *frame = m_dlg->plainPage();
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 5 );
QLabel *pic = new QLabel( frame );
pic->setPixmap( DesktopIcon( "personal" ) );
pic->setMargin( 10 );
QLabel *text = new QLabel( i18n( "Please specify a user name." ), frame );
QLabel *userLabel = new QLabel( i18n( "User:" ), frame );
KComboBox *userCombo = new KComboBox( true, frame, "UserComboBox" );
userCombo->setDuplicatesEnabled( false );
QSpacerItem *spacer1 = new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Preferred );
layout->addWidget( pic, 0, 0, 0 );
layout->addMultiCellWidget( text, 0, 0, 1, 3, 0 );
layout->addWidget( userLabel, 1, 0, 0 );
layout->addMultiCellWidget( userCombo, 1, 1, 1, 4, 0 );
layout->addItem( spacer1, 0, 2 );
connect( userCombo, SIGNAL( textChanged( const QString &) ),
this, SLOT( slotTextChanged( const QString & ) ) );
connect( m_dlg, SIGNAL( user1Clicked() ),
this, SLOT( slotClearClicked() ) );
// Read the list of logins, that are already defined
// for this 'homes' share.
QStringList list = read_names( host );
if ( !list.isEmpty() )
{
userCombo->insertStringList( list, -1 );
m_dlg->enableButton( KDialogBase::User1, true );
}
userCombo->setCurrentText( QString::null );
// Do the last things before showing.
userCombo->setFocus();
m_dlg->setFixedSize( m_dlg->sizeHint() );
if ( m_dlg->exec() == KDialogBase::Accepted )
{
// First make sure, the list is cleared:
list.clear();
// Write the new list of logins to the config file.
if ( !userCombo->lineEdit()->text().isEmpty() )
{
list.append( userCombo->lineEdit()->text() );
}
int index = 0;
while ( index < userCombo->count() )
{
if ( list.find( userCombo->text( index ) ) == list.end() )
{
list.append( userCombo->text( index ) );
}
index++;
}
list.sort();
write_names( host, list );
username = userCombo->currentText();
}
delete m_dlg;
m_dlg = NULL;
return username;
}
const QStringList &Smb4KHomesSharesHandler::read_names( const QString &host )
{
// Clear the old contents of this list:
m_names.clear();
QFile file( locateLocal( "data", "smb4k/homes_shares", KGlobal::instance() ) );
if ( file.open( IO_ReadOnly ) )
{
QTextStream ts( &file );
ts.setEncoding( QTextStream::Locale );
QString line;
bool get_names = false;
while ( !ts.atEnd() )
{
line = ts.readLine();
if ( !get_names )
{
if ( QString::compare( line.stripWhiteSpace(), "["+host.upper()+"]" ) == 0 )
{
// Found the host:
get_names = true;
continue;
}
else
{
// No match yet...
continue;
}
}
else
{
if ( !line.stripWhiteSpace().isEmpty() )
{
// Write the names to the list:
m_names = QStringList::split( ",", line, false );
// This is not needed, but let's do it anyway:
get_names = false;
break;
}
}
}
file.close();
}
else
{
if ( file.exists() )
{
Smb4KError::error( ERROR_READING_FILE, file.name() );
// The list is empty:
return m_names;
}
}
return m_names;
}
void Smb4KHomesSharesHandler::write_names( const QString &host, const QStringList &names )
{
// First get the whole contents of the file, so that
// we can easily modify it:
QStringList contents;
QFile file( locateLocal( "data", "smb4k/homes_shares", KGlobal::instance() ) );
if ( file.open( IO_ReadOnly ) )
{
QTextStream ts( &file );
ts.setEncoding( QTextStream::Locale );
contents = QStringList::split( '\n', ts.read(), true );
file.close();
}
else
{
if ( file.exists() )
{
Smb4KError::error( ERROR_READING_FILE, file.name() );
return;
}
}
// Now search for the host:
QStringList::Iterator it;
for ( it = contents.begin(); it != contents.end(); ++it )
{
if ( QString::compare( (*it).stripWhiteSpace().upper(), "["+host.upper()+"]" ) == 0 )
{
if ( !names.isEmpty() )
{
// Move to the line with the names:
it++;
// Change the line:
*it = names.join( "," );
}
else
{
// Remove the host entry:
it = contents.remove( it );
// Remove the user names:
it = contents.remove( it );
// Remove the blank line following the entry:
if ( it != contents.end() && (*it).stripWhiteSpace().isEmpty() )
{
contents.remove( it );
}
}
break;
}
else
{
continue;
}
}
// If we haven't found the host, append it to the end:
if ( it == contents.end() )
{
if ( !contents.isEmpty() )
{
contents.append( "" );
}
contents.append( "["+host.upper()+"]");
contents.append( names.join( "," ) );
}
// Now write or remove the file:
if ( !contents.isEmpty() )
{
if ( file.open( IO_WriteOnly ) )
{
QTextStream ts( &file );
ts.setEncoding( QTextStream::Locale );
ts << contents.join( "\n" );
file.close();
}
else
{
Smb4KError::error( ERROR_WRITING_FILE, file.name() );
return;
}
}
else
{
file.remove();
}
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KHomesSharesHandler::slotTextChanged( const QString &text )
{
if ( !text.isEmpty() )
{
m_dlg->enableButtonOK( true );
}
else
{
m_dlg->enableButtonOK( false );
}
}
void Smb4KHomesSharesHandler::slotClearClicked()
{
if ( m_dlg )
{
KComboBox *cb = (KComboBox *)m_dlg->child( "UserComboBox", "KComboBox", true );
if ( cb )
{
cb->clearEdit();
cb->clear();
m_dlg->enableButton( KDialogBase::User1, false );
}
}
}
#include "smb4khomesshareshandler.moc"

@ -0,0 +1,139 @@
/***************************************************************************
smb4khomesshareshandler - This class handles the homes shares.
-------------------
begin : Do Aug 10 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 *
***************************************************************************/
#ifndef SMB4KHOMESSHARESHANDLER_H
#define SMB4KHOMESSHARESHANDLER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
// KDE includes
#include <kdialogbase.h>
#include <kconfig.h>
/**
* This class belongs to the core of Smb4K and takes care of the
* user names that are/were defined for a certain 'homes' share.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KHomesSharesHandler : public QObject
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent object of this class
*
* @param name The name of this class
*/
Smb4KHomesSharesHandler( QObject *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KHomesSharesHandler();
/**
* This function will open a dialog where the user has to define a
* user name to access a 'homes' share. Besides returning this name,
* this function will also store the name in the configuration file.
*
* @param host The host where the homes share is located
*
* @param parent The parent widget
*
* @param name The name of this dialog
*
* @returns A user name
*/
const QString specifyUser( const QString &host, QWidget *parent = 0, const char *name = 0 );
/**
* Read and return the user names that are defined for a homes share.
*
* @param host The name of the host where the 'homes' share is located.
*
* @returns the list of user names for this homes share.
*/
const QStringList &homesUsers( const QString &host ) { return read_names( host ); }
protected slots:
/**
* Is connected to the textChanged() signal of the combo box
* in the "Specify User" dialog.
*
* @param text The text in the combo box
*/
void slotTextChanged( const QString &text );
/**
* This slot is called if the User1 button, i.e. the "Clear" button
* in the "Specify User" dialog has been clicked. It removes all
* entries from the combo box.
*/
void slotClearClicked();
private:
/**
* Read the user names for a homes share.
*
* @param host The host where the homes share is located.
*/
const QStringList &read_names( const QString &host );
/**
* Write the user names for a certain homes share to the config
* file.
*
* @param host The host where the homes share is located
*
* @param names The list of user names that are defined for
* the homes share and should be written to the
* config file.
*/
void write_names( const QString &host, const QStringList &names );
/**
* This is the dialog that's shown the user when he/she has to
* provide a user name.
*/
KDialogBase *m_dlg;
/**
* This is a buffer for the list of names defined for a 'homes' share.
*/
QStringList m_names;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,343 @@
/***************************************************************************
smb4kmounter.h - The core class that mounts the shares.
-------------------
begin : Die Jun 10 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KMOUNTER_H
#define SMB4KMOUNTER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstringlist.h>
#include <qptrqueue.h>
#include <qfile.h>
// KDE includes
#include <kprocess.h>
// application specific includes
#include "smb4kdefs.h"
// forward declarations
class Smb4KMounterPrivate;
class Smb4KShare;
/**
* This is one of the core classes of Smb4K. It manages the mounting
* and unmounting of remote Samba/Windows shares. Additionally it maintains a
* list of all mounts with SMBFS and CIFS file system that are present
* on the system.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KMounter : public QObject
{
Q_OBJECT
public:
/**
* The constructor.
*/
Smb4KMounter( QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KMounter();
/**
* Aborts a running process.
*/
void abort();
/**
* Enumeration for the state of the process. The members are also
* used in the results() signal as return values.
*/
enum State{ Remount, Import, Mount, Unmount, UnmountAll, Idle };
/**
* Unmounts a share. This can either be done the "normal" way, or you may
* force it. If you decide the force the unmounting by setting @p force to TRUE,
* a lazy unmount will be initiated. With the parameter @p noMessage you can
* suppress any error messages.
*
* @param share The share object that should be unmounted.
*
* @param force Force the unmounting of the share.
*
* @param noMessage Determines whether this function should emit an error code in case of an error.
* The default value is FALSE.
*/
void unmountShare( Smb4KShare *share, bool force = false, bool noMessage = false );
/**
* Unmounts all shares at once.
*/
void unmountAllShares();
/**
* Mounts a share.
*
* @param workgroup The workgroup of the share.
*
* @param host The server where the share is located.
*
* @param ip The IP address of the host.
*
* @param share The name of the share.
*/
void mountShare( const QString &workgroup, const QString &host, const QString &ip, const QString &share );
/**
* Returns the unsorted list of mounted shares.
*/
const QValueList<Smb4KShare *> &getShares() { return m_mounted_shares; };
/**
* Find a share in the list with its path.
*/
Smb4KShare* findShareByPath( const QString &path );
/**
* Find all mounts of the particular share @p share on the system.
*
* @param name The name of the share
*
* @returns the complete list of mounts of @p share.
*/
QValueList<Smb4KShare> findShareByName( const QString &name );
/**
* This function returns TRUE if a share is mounted and FALSE otherwise.
*
* @param name The name of the share. It has to look like this:
* //HOST/SHARE.
*
* @param userOnly Specifies whether this function should only consider
* shares mounted by the user or all shares that are
* available on the system. The default is TRUE.
*
* @return TRUE if the share is mounted and FALSE otherwise.
*/
bool isMounted( const QString &name, bool userOnly = true );
/**
* This function reports if the mounter is running or not.
*
* @returns TRUE if the scanner is running and FALSE otherwise.
*/
bool isRunning() { return m_working; }
/**
* This function returns the list of broken shares.
*
* @returns The list of broken shares.
*/
const QValueList<Smb4KShare *> getBrokenShares();
/**
* This function executes Smb4KMounter::slotShutdown(). Under normal circumstances,
* there is no need to use this function, because everything that is done here is
* also done when KApplication::shutDown() is emitted. However, it comes in handy
* when you need to perform last actions in a plugin.
*/
void prepareForShutdown();
/**
* This function initializes import of mounted shares and the remounting of recently
* used shares.
*/
void init();
signals:
/**
* This signal emits the run state.
*
* @param state The so-called run state. There are several defined
* in the smb4kdefs.h header file.
*/
void state( int state );
/**
* Tells the program, that the shares list has been updated.
*/
void updated();
/**
* This signal is emitted when a share has successfully been mounted or
* if it has already been mounted.
*
* @param mountpoint The mount point of the share.
*/
void mountedShare( const QString &mountpoint );
/**
* This signal is emitted just before a share is unmounted.
*
* @param mountpoint The mount point of the share that is going to
* be unmounted.
*/
void aboutToUnmount( const QString &mountpoint );
protected:
/**
* Starts a process. It takes an interger, that determines,
* which process has to be started.
*/
void startProcess( int state );
/**
* Is called, when the process ended.
*/
void endProcess();
/**
* Finishes the mounting of shares.
*/
void processMount();
/**
* Finishes the unmounting of a single share.
*/
void processUnmount();
/**
* Reimplemented from QObject
*/
void timerEvent( QTimerEvent *e );
protected slots:
/**
* Is called, when the process exits.
*/
void slotProcessExited( KProcess * );
/**
* Is called, if output is received on Stdout.
*/
void slotReceivedStdout( KProcess *, char *buf, int len );
/**
* Is called, if output is received on Stderr.
*/
void slotReceivedStderr( KProcess *, char *buf, int len );
/**
* This slot is called by the KApplication::shutDown() signal.
* Is does everything that has to be done before the program
* really exits.
*/
void slotShutdown();
private:
/**
* Remount shares that were used in the last session.
*/
void remount();
/**
* Imports mounted shares.
*/
void import();
/**
* Mounts a selected share.
*/
void mount( const QString &workgroup, const QString &host, const QString &ip, const QString &share );
/**
* Unmounts the selected item.
*/
void unmount( const QString &mountpoint, bool noMessage, bool force = false );
/**
* Unmounts all shares at once.
*/
void unmountAll();
/**
* Checks if the share @p share is accessible or not and sets Smb4KShare::isBroken()
* accordingly. Additionally, Smb4KShare::totalDiskSpace() and Smb4KShare::freeDiskSpace()
* are set to the current values.
*
* @param share The share that should be checked.
*/
void checkAccessibility( Smb4KShare *share );
/**
* The KProcess object.
*/
KProcess *m_proc;
/**
* The buffer.
*/
QString m_buffer;
/**
* The queue, where the incoming requests are stored.
*/
QPtrQueue<QString> m_queue;
/**
* Determines, whether the mounter is running or not.
*/
bool m_working;
/**
* Holds the list of currently mounted shares as a pointer list.
*/
QValueList<Smb4KShare *> m_mounted_shares;
/**
* Makes sure that the error message concerning the missing of
* the file /proc/mounts is only shown once.
*/
bool m_proc_error;
/**
* The internal state of the process. Do not mix this up with
* the state that's emitted to notify the application about changes.
*/
int m_state;
#ifndef __FreeBSD__
/**
* This file object points to /proc/mounts.
*/
QFile m_proc_mounts;
#endif
/**
* This is the pointer to the private helper class.
*/
Smb4KMounterPrivate *m_priv;
};
#endif

@ -0,0 +1,135 @@
/***************************************************************************
smb4kmounter_p - This is a private helper class for Smb4KMounter.
-------------------
begin : Do Jul 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// application specific includes
#include "smb4kmounter_p.h"
Smb4KMounterPrivate::Smb4KMounterPrivate()
{
timerTicks = 0;
clearData();
}
Smb4KMounterPrivate::~Smb4KMounterPrivate()
{
}
void Smb4KMounterPrivate::clearData()
{
m_workgroup = QString::null;
m_host = QString::null;
m_share = QString::null;
m_ip = QString::null;
m_path = QString::null;
m_filesystem = QString::null;
m_cifsLogin = QString::null;
}
const QString &Smb4KMounterPrivate::workgroup()
{
return m_workgroup;
}
const QString &Smb4KMounterPrivate::host()
{
return m_host;
}
const QString &Smb4KMounterPrivate::share()
{
return m_share;
}
const QString &Smb4KMounterPrivate::ip()
{
return m_ip;
}
const QString &Smb4KMounterPrivate::path()
{
return m_path;
}
const QString &Smb4KMounterPrivate::filesystem()
{
return m_filesystem;
}
const QString &Smb4KMounterPrivate::cifsLogin()
{
return m_cifsLogin;
}
void Smb4KMounterPrivate::setWorkgroup( const QString &wg )
{
m_workgroup = wg;
}
void Smb4KMounterPrivate::setHost( const QString &h )
{
m_host = h;
}
void Smb4KMounterPrivate::setShare( const QString &s )
{
m_share = s;
}
void Smb4KMounterPrivate::setIP( const QString &i )
{
m_ip = i;
}
void Smb4KMounterPrivate::setPath( const QString &p )
{
m_path = p;
}
void Smb4KMounterPrivate::setFileSystem( const QString &f )
{
m_filesystem = f;
}
void Smb4KMounterPrivate::setCIFSLogin( const QString &l )
{
m_cifsLogin = l;
}

@ -0,0 +1,126 @@
/***************************************************************************
smb4kmounter_p - This is a private helper class for Smb4KMounter.
-------------------
begin : Do Jul 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KMOUNTER_P_H
#define SMB4KMOUNTER_P_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qthread.h>
#include <qstring.h>
// KDE includes
#include <kdebug.h>
// system includes
#include <sys/statvfs.h>
class Smb4KMounterPrivate
{
public:
Smb4KMounterPrivate();
~Smb4KMounterPrivate();
int timerTicks;
class Thread : public QThread
{
public:
Thread() : QThread(), m_mountpoint( QString::null ), m_broken( true ) {}
~Thread() {}
void setMountpoint( const QString &mp ) { m_mountpoint = mp; }
virtual void run()
{
if ( m_mountpoint.isEmpty() )
{
kdFatal() << "Smb4KMounterPrivate::Thread: No mountpoint specified" << endl;
}
struct statvfs fs;
if ( statvfs( m_mountpoint.local8Bit(), &fs ) == -1 )
{
m_broken = true;
m_total = -1;
m_free = -1;
}
else
{
m_broken = false;
double kB_block = (double)(fs.f_bsize / 1024);
double total = (double)(fs.f_blocks*kB_block);
double free = (double)(fs.f_bfree*kB_block);
m_total = total;
m_free = free;
}
m_mountpoint = QString::null;
}
bool isBroken() { return m_broken; }
double totalDiskSpace() { return m_total; }
double freeDiskSpace() { return m_free; }
private:
QString m_mountpoint;
bool m_broken;
double m_total;
double m_free;
};
Thread thread;
void clearData();
const QString &workgroup();
const QString &host();
const QString &share();
const QString &ip();
const QString &path();
const QString &filesystem();
const QString &cifsLogin();
void setWorkgroup ( const QString &wg );
void setHost( const QString &h );
void setShare( const QString &s );
void setIP( const QString &i );
void setPath( const QString &p );
void setFileSystem( const QString &f );
void setCIFSLogin( const QString &l );
private:
QString m_workgroup;
QString m_host;
QString m_share;
QString m_ip;
QString m_path;
QString m_filesystem;
QString m_cifsLogin;
};
#endif

@ -0,0 +1,239 @@
/***************************************************************************
smb4knetworkitems - Network items used by the Smb4KScanner class
to pass and store data.
-------------------
begin : Mi Jun 2 2004
copyright : (C) 2004 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 <klocale.h>
#include <ksocketaddress.h>
// application specific includes
#include "smb4knetworkitems.h"
/****************************************************************************
Smb4KWorkgroupItem class
****************************************************************************/
Smb4KWorkgroupItem::Smb4KWorkgroupItem( const QString &name, const QString &master, const QString &masterIP )
: m_name( name ), m_master( master ), m_pseudo( false )
{
m_ip = ipIsValid( masterIP ) ? masterIP : QString::null;
}
Smb4KWorkgroupItem::~Smb4KWorkgroupItem()
{
}
void Smb4KWorkgroupItem::setPseudoMaster()
{
m_pseudo = true;
}
void Smb4KWorkgroupItem::setMasterIP( const QString &ip )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
void Smb4KWorkgroupItem::setMaster( const QString &name, const QString &ip, bool pseudo )
{
m_master = name;
m_ip = ipIsValid( ip ) ? ip : QString::null;
m_pseudo = pseudo;
}
bool Smb4KWorkgroupItem::ipIsValid( const QString &ip )
{
if ( !ip.isEmpty() )
{
KNetwork::KIpAddress ip_address = KNetwork::KIpAddress( ip );
if ( !ip_address.isIPv4Addr() && !ip_address.isIPv6Addr() )
{
return false;
}
}
else
{
return false;
}
return true;
}
/****************************************************************************
Smb4KHostItem class
****************************************************************************/
Smb4KHostItem::Smb4KHostItem( const QString &workgroup, const QString &name, const QString &comment, const QString &ip )
: m_workgroup( workgroup ), m_name( name ), m_comment( comment ), m_server_string( QString::null ),
m_os_string( QString::null ), m_master( false ), m_ip_checked( m_ip.stripWhiteSpace().isEmpty() ? false : true ),
m_info_checked( false )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
Smb4KHostItem::Smb4KHostItem( const Smb4KHostItem &host )
: m_workgroup( host.workgroup() ), m_name( host.name() ), m_comment( host.comment() ), m_ip( host.ip() ),
m_server_string( host.serverString() ), m_os_string( host.osString() ), m_master( host.isMaster() ),
m_ip_checked( host.ipAddressChecked() ), m_info_checked( host.infoChecked() )
{
// NOTE: We do not check the IP address here, because that has
// already been done by the copied Smb4KHostItem object.
}
Smb4KHostItem::~Smb4KHostItem()
{
}
void Smb4KHostItem::setServerString( const QString &server )
{
m_server_string = server;
}
void Smb4KHostItem::setOSString( const QString &os )
{
m_os_string = os;
}
void Smb4KHostItem::setMaster( bool master )
{
m_master = master;
}
void Smb4KHostItem::setIPAddress( const QString &ip )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
void Smb4KHostItem::setComment( const QString &comment )
{
m_comment = comment;
}
void Smb4KHostItem::setIPAddressChecked( bool yes )
{
m_ip_checked = yes;
}
void Smb4KHostItem::setInfoChecked( bool yes )
{
m_info_checked = yes;
}
bool Smb4KHostItem::ipIsValid( const QString &ip )
{
if ( !ip.isEmpty() )
{
KNetwork::KIpAddress ip_address = KNetwork::KIpAddress( ip );
if ( !ip_address.isIPv4Addr() && !ip_address.isIPv6Addr() )
{
return false;
}
}
else
{
return false;
}
return true;
}
/****************************************************************************
Smb4KShareItem class
****************************************************************************/
Smb4KShareItem::Smb4KShareItem( const QString &workgroup, const QString &host, const QString &name, const QString &type, const QString &comment )
: m_workgroup( workgroup ), m_host( host ), m_name( name ), m_type( type ), m_comment( comment )
{
}
Smb4KShareItem::~Smb4KShareItem()
{
}
const QString Smb4KShareItem::translatedType() const
{
QString return_string;
if ( QString::compare( m_type, "Disk" ) == 0 )
{
return_string = i18n( "Disk" );
}
else if ( QString::compare( m_type, "Print" ) == 0 || QString::compare( m_type, "Printer" ) == 0 )
{
return_string = i18n( "Printer" );
}
else
{
return_string = m_type;
}
return return_string;
}
bool Smb4KShareItem::isHidden() const
{
return m_name.stripWhiteSpace().endsWith( "$" );
}
bool Smb4KShareItem::isPrinter() const
{
return (QString::compare( m_type, "Print" ) == 0 || QString::compare( m_type, "Printer" ) == 0);
}
bool Smb4KShareItem::isIPC() const
{
return (QString::compare( m_name.stripWhiteSpace(), "IPC$" ) == 0);
}
bool Smb4KShareItem::isADMIN() const
{
return (QString::compare( m_name.stripWhiteSpace(), "ADMIN$" ) == 0);
}

@ -0,0 +1,487 @@
/***************************************************************************
smb4knetworkitems - Network items used by the Smb4KScanner class
to pass and store data.
-------------------
begin : Mi Jun 2 2004
copyright : (C) 2004 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 *
***************************************************************************/
#ifndef SMB4KNETWORKITEMS_H
#define SMB4KNETWORKITEMS_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstring.h>
/**
* This class provides a container for a workgroup/domain found in the network
* neighborhood.
*/
class Smb4KWorkgroupItem
{
public:
/**
* The constructor.
*
* @param name The name of the workgroup/domain.
*
* @param master The master browser of the workgroup.
*
* @param masterIP The IP address of the workgroup master browser.
*/
Smb4KWorkgroupItem( const QString &name,
const QString &master,
const QString &masterIP = QString::null );
/**
* Empty constructor.
*/
Smb4KWorkgroupItem() {}
/**
* The destructor.
*/
~Smb4KWorkgroupItem();
/**
* Returns the workgroup name.
*/
const QString &name() const { return m_name; }
/**
* Returns the name of the master browser.
*/
const QString &master() const { return m_master; }
/**
* Returns the IP address of the master browser. If it is not a valid
* IPv4 or IPv6 address, QString::null is returned.
*
* @returns the valid IP v4 or v6 address of the workgroup master browser
* or QString::null.
*/
const QString &masterIP() const { return m_ip; }
/**
* You can mark the master as 'pseudo' with this function. That means that
* this master was not reported as being the master browser of this
* workgroup, but it's the only one found (e.g. by a custom search).
*/
void setPseudoMaster();
/**
* Returns TRUE, if the master is a 'pseudo' master. @see setPseudoMaster()
* for further information.
*/
bool hasPseudoMaster() const { return m_pseudo; }
/**
* This function sets the IP address of the master browser.
*
* @param ip The IP address of the master browser
*/
void setMasterIP( const QString &ip );
/**
* This function sets the master browser.
*
* @param name The name of the master browser
*
* @param ip The IP address of the master browser
*
* @param pseudo Determines if this is a real master browser or if
* it is a faked one, i.e. a pseudo master.
*/
void setMaster( const QString &name,
const QString &ip,
bool pseudo = false );
private:
/**
* The name of the workgroup.
*/
QString m_name;
/**
* The name of the workgroup master.
*/
QString m_master;
/**
* The IP address of the master.
*/
QString m_ip;
/**
* Determines whether the master is a 'pseudo'-master.
*/
bool m_pseudo;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const QString &ip );
};
/**
* This class provides a container for a host found in the network
* neighborhood.
*/
class Smb4KHostItem
{
public:
/**
* The default constructor.
*
* @param workgroup The workgroup/domain of the host
*
* @param name The name of the host
*
* @param comment The comment that describes the host. May be empty.
*
* @param ip The IP address of the host
*/
Smb4KHostItem( const QString &workgroup,
const QString &name,
const QString &comment = QString::null,
const QString &ip = QString::null );
/**
* The copy constructor.
*
* @param host A Smb4KHostItem representing a host.
*/
Smb4KHostItem( const Smb4KHostItem &host );
/**
* The empty constructor.
*/
Smb4KHostItem() {}
/**
* The destructor.
*/
~Smb4KHostItem();
/**
* Returns the workgroup the host is in.
*/
const QString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the host.
*/
const QString &name() const { return m_name; }
/**
* Returns the IP address of the host.
*/
const QString &ip() const { return m_ip; }
/**
* Returns the comment for this host.
*/
const QString &comment() const { return m_comment; }
/**
* Sets the Server string that is reported by the host.
*/
void setServerString( const QString &server );
/**
* Returns the Server string.
*/
const QString &serverString() const { return m_server_string; }
/**
* Sets the OS string that is reported by the host.
*/
void setOSString( const QString &os );
/**
* Returns the OS string.
*/
const QString &osString() const { return m_os_string; }
/**
* This functions determines whether this host should be
* registered as a master browser.
*
* @param master Set this to TRUE if the host is a master browser.
*/
void setMaster( bool master );
/**
* This function tells you if the host is a master or not.
*
* @returns TRUE if the host is a master browser.
*/
const bool isMaster() const { return m_master; }
/**
* This function sets the IP address of a host.
*
* @param ip The IP address of a host
*/
void setIPAddress( const QString &ip );
/**
* This function sets the command for a host.
*
* @param comment The comment
*/
void setComment( const QString &comment );
/**
* This function is used to tell the host item, if a
* check for the IP address has already been performed.
*
* @param yes Should be set to TRUE if a check was performed.
*/
void setIPAddressChecked( bool yes );
/**
* Tells if a check for the IP address has already been performed.
*
* @returns TRUE if a check was performed, and FALSE otherwise.
*/
const bool ipAddressChecked() const { return m_ip_checked; }
/**
* This function is used to tell the host item, if a
* check for the information (OS and Server string ) has already been performed.
*
* @param yes Should be set to TRUE if a check was performed.
*/
void setInfoChecked( bool yes );
/**
* Tells if a check for the information (OS and Server string) has already
* been performed.
*
* @returns TRUE is the check was performed previously.
*/
const bool infoChecked() const { return m_info_checked; }
private:
/**
* The name of the workgroup.
*/
QString m_workgroup;
/**
* The name of the host.
*/
QString m_name;
/**
* The comment for this host.
*/
QString m_comment;
/**
* The IP address of the host.
*/
QString m_ip;
/**
* The Server string as reported by the host.
*/
QString m_server_string;
/**
* The operating system string as reported by the host.
*/
QString m_os_string;
/**
* This boolian determines if the host is a master browser
* or not.
*/
bool m_master;
/**
* This boolean tells if a check for the IP address was already
* performed.
*/
bool m_ip_checked;
/**
* This boolean tells if a check for the information (OS and server string)
* was already performed.
*/
bool m_info_checked;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const QString &ip );
};
/**
* This class provides a container for a share found in the
* network neighborhood.
*/
class Smb4KShareItem
{
public:
/**
* The constructor.
*
* @param workgroup The workgroup/domain name.
*
* @param host The name of the host where the share is located.
*
* @param name The name of the share.
*
* @param type The type of the share as returned by the Samba programs, i.e.
* "Disk", "Printer", "IPC$" or "ADMIN$".
*
* @param comment The comment of the share.
*/
Smb4KShareItem( const QString &workgroup,
const QString &host,
const QString &name,
const QString &type,
const QString &comment );
/**
* Empty constructor.
*/
Smb4KShareItem() {}
/**
* The destructor.
*/
~Smb4KShareItem();
/**
* Returns the workgroup of the host where the share is located.
*/
const QString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the host where the share is located.
*/
const QString &host() const { return m_host; }
/**
* Returns the name of the share.
*/
const QString &name() const { return m_name; }
/**
* Returns the type of the share.
*/
const QString &plainType() const { return m_type; }
/**
* Returns a translated version of the type of the share.
*
* @returns The translated share type
*/
const QString translatedType() const;
/**
* Returns the comment for this share.
*/
const QString &comment() const { return m_comment; }
/**
* This function tells if the share is a hidden one.
*
* @returns TRUE is the share is a hidden one and FALSE otherwise.
*/
bool isHidden() const;
/**
* This function is TRUE if the share is a printer and
* FALSE otherwise.
*
* @returns TRUE if the share is a printer
*/
bool isPrinter() const;
/**
* This function returns TRUE if the share is an IPC$
* share and FALSE otherwise.
*
* @returns TRUE if the share is an IPC$ share
*/
bool isIPC() const;
/**
* This function returns TRUE if the share is an ADMIN$
* share and FALSE otherwise.
*
* @returns TRUE if the share is an ADMIN$ share
*/
bool isADMIN() const;
private:
/**
* The workgroup object.
*/
QString m_workgroup;
/**
* The host name.
*/
QString m_host;
/**
* The name of the share.
*/
QString m_name;
/**
* The type of the share.
*/
QString m_type;
/**
* The comment for this share.
*/
QString m_comment;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,305 @@
/***************************************************************************
smb4kpasswordhandler - This class handles the passwords for Smb4K.
-------------------
begin : So Jan 16 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KPASSWORDHANDLER_H
#define SMB4KPASSWORDHANDLER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qcheckbox.h>
// KDE includes
#include <kwallet.h>
#include <kdialogbase.h>
#include <kprocess.h>
// forward declarations
#ifndef __FreeBSD__
class Smb4KAuthInfo;
#endif
// application specific includes
#include "smb4khomesshareshandler.h"
#ifdef __FreeBSD__
#include "smb4ksambaoptionshandler.h"
#include "smb4kauthinfo.h"
#endif
/**
* This class handles the passwords used by Smb4K to authenticate to
* the network shares.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPasswordHandler : public QObject
{
Q_OBJECT
public:
#ifndef __FreeBSD__
/**
* The constructor.
*
* @param config The KConfig object that should be used
*
* @param handler The Smb4KHomesSharesHandler object that is needed to retrieve
* infos in case we need to look up authentication information for
* 'homes' shares.
*
* @param parent The parent object.
*
* @param name The name this class should carry.
*/
Smb4KPasswordHandler( Smb4KHomesSharesHandler *handler,
QObject *parent = 0,
const char *name = 0 );
#else
/**
* The constructor (FreeBSD).
*
* @param s_handler The Smb4KHomesSharesHandler object that is needed to retrieve
* infos in case we need to look up authentication information for
* 'homes' shares.
*
* @param o_handler The Smb4KSambaOptionsHandler object. It is needed to write the
* ~/.nsmbrc file correctly.
*
* @param parent The parent object.
*
* @param name The name this class should carry.
*/
Smb4KPasswordHandler( Smb4KHomesSharesHandler *s_handler,
Smb4KSambaOptionsHandler *o_handler,
QObject *parent = 0,
const char *name = 0 );
#endif
/**
* The destructor.
*/
~Smb4KPasswordHandler();
/**
* Opens the askpass dialog.
*
* @param workgroup The workgroup where the share is located in (may be empty).
*
* @param host The host the share belongs to.
*
* @param name The name of the share.
*
* @param desc Determines which descriptive label the askpass dialog should carry.
* Values are taken from the Smb4KPasswordHandler::AskPass::Description
* enumeration.
*
* @param parent The parent of this dialog.
*
* @param name The name of this dialog.
*
* @returns TRUE if a new password has been supplied and FALSE otherwise.
*/
bool askpass( const QString &workgroup, const QString &host, const QString &share, int desc, QWidget *parent = 0, const char *name = 0 );
/**
* Returns the authentication data that was found for the defined share. You need to
* provide the workgroup, host name, and share name with @p authInfo.
*
* @param authInfo The authentication information object.
*
* @returns a pointer to @p authInfo. This may be NULL if @p authInfo was
* also NULL.
*/
Smb4KAuthInfo *readAuth( Smb4KAuthInfo *authInfo );
/**
* Write the provided authentication data to the wallet.
*
* @param authInfo The Smb4KAuthInfo object that holds the authentication information.
*/
void writeAuth( Smb4KAuthInfo *authInfo );
/**
* Read the default authentication from the wallet.
*
* @param authInfo The authentication information object.
*
* @returns pointer to the authentication data object if a wallet is used or NULL otherwise
*/
Smb4KAuthInfo *readDefaultAuth( Smb4KAuthInfo *authInfo );
/**
* Writes the default authentication data to the wallet. This function seems only to
* be useful for the configuration dialog.
*
* @param authInfo The authentication data for the default login if a wallet is
* used or NULL otherwise.
*/
void writeDefaultAuth( Smb4KAuthInfo *authInfo );
/**
* This enumeration destermines which destriptive label the askpass
* dialog should carry.
*/
enum Description{ NewData, AccessDenied, BadPassword, PermDenied, AuthError, LogonFailure, None };
/**
* This function returns TRUE if the wallet it open at the moment and FALSE
* if it is closed or not used.
*
* @returns TRUE if the wallet is open.
*/
bool walletIsOpen() { return (m_wallet && m_wallet->isOpen()); }
/**
* This function returns TRUE if the digital wallet support has been
* disabled. This happens when the wallet could not be opened.
*
* @returns TRUE if the digital wallet support has been disabled.
*/
bool walletSupportIsDisabled() { return m_wallet_support_disabled; }
protected slots:
/**
* Get the password for a specific share and user name.
*/
void slotGetPassword( const QString &username );
/**
* This slot is used to enable the OK button of the askpass
* dialog when text has been entered in the text boxes and/or the
* combo box.
*
* @param text The text that has been entered.
*/
void slotEnableOKButton( const QString &text );
/**
* FreeBSD specific: This slot receives output from the process that encrypts
* the passwords.
*
* @param proc The process that sends the output
*
* @param buffer The buffer that contains the output
*
* @param buflen The length of the buffer
*/
void slotReceivePassword( KProcess *proc, char *buffer, int buflen );
/**
* FreeBSD specific: This slot is invoked if the process exited.
*
* @param proc The process that exited
*/
void slotWritePassword( KProcess *proc );
private:
/**
* This function opens the wallet in which the passwords should be
* stored.
*/
void open_close_wallet();
/**
* This function is used to convert old wallet entries to the new
* map based ones.
*/
void convert_old_entries();
/**
* The KWallet object.
*/
KWallet::Wallet *m_wallet;
/**
* The Smb4KAuthInfo object. For use with the askpass dialog.
*/
Smb4KAuthInfo *m_auth;
/**
* The askpass dialog.
*/
KDialogBase *m_dlg;
/**
* This list holds the authentication data the user supplied if he/she
* does not want to use KWallet.
*/
QValueList<Smb4KAuthInfo *> m_auth_list;
/**
* If the user neither wants to store the passwords in a wallet nor in a
* temporary list, the authentication data received from the askpass dialog
* will the stored in this object.
*/
Smb4KAuthInfo *m_temp_auth;
/**
* The Smb4KHomesSharesHandler object
*/
Smb4KHomesSharesHandler *m_handler;
/**
* Is the wallet support disabled?
*/
bool m_wallet_support_disabled;
#ifdef __FreeBSD__
/**
* FreeBSD specific: This function writes authentication information
* to the ~/.nsmbrc file, which is used by mount_smbfs.
*
* @param authInfo The authentication information that should be written
* to ~/.nsmbrc file.
*/
void writeToSMBConfFile( Smb4KAuthInfo *authInfo );
/**
* FreeBSD specific: Holds the authentication information that should
* be written to ~/.nsmbrc.
*/
Smb4KAuthInfo m_nsmbrc_auth;
/**
* The buffer for the process that encrypts the password.
*/
QString m_buffer;
/**
* The Smb4KSambaOptionsHandler object.
*/
Smb4KSambaOptionsHandler *m_options_handler;
#endif
};
#endif

@ -0,0 +1,361 @@
/***************************************************************************
smb4kpreviewer - This class queries a remote share for a preview
-------------------
begin : Mo Mai 28 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qapplication.h>
// KDE includes
#include <kapplication.h>
#include <kdebug.h>
// application specific includes
#include "smb4kpreviewer.h"
#include "smb4kpreviewitem.h"
#include "smb4kdefs.h"
#include "smb4kglobal.h"
#include "smb4kpasswordhandler.h"
#include "smb4kauthinfo.h"
#include "smb4ksambaoptionshandler.h"
#include "smb4kerror.h"
using namespace Smb4KGlobal;
Smb4KPreviewer::Smb4KPreviewer( QObject *parent, const char *name )
: QObject( parent, name )
{
m_item = NULL;
m_buffer = QString::null;
m_working = false;
m_proc = new KProcess( this, "PreviewProcess" );
m_proc->setUseShell( true );
connect( m_proc, SIGNAL( receivedStdout( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStdout( KProcess *, char *, int ) ) );
connect( m_proc, SIGNAL( processExited( KProcess* ) ),
this, SLOT( slotProcessExited( KProcess * ) ) );
connect( m_proc, SIGNAL( receivedStderr( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStderr( KProcess *, char *, int ) ) );
}
Smb4KPreviewer::~Smb4KPreviewer()
{
// Do not delete m_item here, because it belongs to an
// outside class.
}
bool Smb4KPreviewer::preview( Smb4KPreviewItem *item )
{
// If there is no item, stop right here.
if ( !item )
{
return false;
}
if ( QString::compare( item->share(), "homes" ) == 0 )
{
QString share_name = specifyUser( item->host(), kapp->mainWidget() ? kapp->mainWidget() : 0, "SpecifyUser" );
if ( !share_name.isEmpty() )
{
// The Smb4KPreviewItem::setShare() function will take care
// that no share name is overwritten, that is *not* named
// 'homes'.
item->setShare( share_name );
}
else
{
return false;
}
}
m_timer_id = startTimer( TIMER_INTERVAL );
m_queue.enqueue( item );
return true;
}
void Smb4KPreviewer::abort()
{
m_queue.clear();
if ( m_proc->isRunning() )
{
m_proc->kill();
}
}
void Smb4KPreviewer::timerEvent( QTimerEvent * )
{
if ( m_working )
{
return;
}
// Declare the previewer working:
emit state( PREVIEWER_START );
m_working = true;
m_item = m_queue.dequeue();
// Assemble the command.
//
// Here are some things to remember:
// (a) Do not convert the path to local 8 bit. It won't work with umlauts or other
// special characters.
// (b) Do not pass the path unquoted, or you'll get a NT_STATUS_OBJECT_NAME_NOT_FOUND
// error message in the case the path is empty.
QString command;
command.append( QString( "smbclient //%1/%2 " ).arg( KProcess::quote( m_item->host() ), KProcess::quote( m_item->share() ) ) );
command.append( QString( " -d1 -W %1 -D %2 " ).arg( KProcess::quote( m_item->workgroup() ), KProcess::quote( m_item->path() ) ) );
command.append( " -c \"ls\" " );
if ( !m_item->ip().isEmpty() )
{
command.append( QString( " -I %1 " ).arg( m_item->ip() ) );
}
command.append( optionsHandler()->smbclientOptions( "//"+m_item->host()+"/"+m_item->share() ) );
Smb4KAuthInfo *auth = passwordHandler()->readAuth( new Smb4KAuthInfo( m_item->workgroup(), m_item->host(), m_item->share() ) );
if ( !auth->user().isEmpty() )
{
command.append( QString( " -U %1" ).arg( KProcess::quote( auth->user() ) ) );
if ( !auth->password().isEmpty() )
{
m_proc->setEnvironment( "PASSWD", auth->password() );
}
}
else
{
command.append( " -U guest%" );
}
delete auth;
*m_proc << command;
QApplication::setOverrideCursor( waitCursor );
m_proc->start( KProcess::NotifyOnExit, KProcess::AllOutput );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KPreviewer::slotReceivedStdout( KProcess *, char *buf, int len )
{
m_buffer.append( QString::fromLocal8Bit( buf, len ) );
}
void Smb4KPreviewer::slotReceivedStderr( KProcess *, char *buf, int len )
{
m_buffer.append( QString::fromLocal8Bit( buf, len ) );
}
void Smb4KPreviewer::slotProcessExited( KProcess * )
{
// Disconnect the timer:
if ( m_queue.isEmpty() )
{
killTimer( m_timer_id );
}
m_proc->clearArguments();
QStringList list = QStringList::split( "\n", m_buffer, false );
m_buffer = QString::null;
// Check whether an error occurred:
if ( list.grep( "NT_STATUS" ).count() != 0 )
{
// Something went wrong. Let's check if this "only" an
// authentication issue or if we have to error out:
QString error_code = list.grep( "NT_STATUS" ).first().stripWhiteSpace().section( " ", 0, 0 );
// The error output of smbclient is a little bit inconsistent:
if ( error_code.contains( "NT_STATUS" ) == 0 )
{
error_code = list.grep( "NT_STATUS" ).first().stripWhiteSpace().section( " ", -1, -1 );
}
// Authentication issue?
if ( QString::compare( error_code, "NT_STATUS_ACCESS_DENIED" ) == 0 ||
QString::compare( error_code, "NT_STATUS_LOGON_FAILURE" ) == 0 )
{
int state = Smb4KPasswordHandler::None;
if ( QString::compare( error_code, "NT_STATUS_ACCESS_DENIED" ) == 0 )
{
state = Smb4KPasswordHandler::AccessDenied;
}
else if ( QString::compare( error_code, "NT_STATUS_LOGON_FAILURE" ) == 0 )
{
state = Smb4KPasswordHandler::LogonFailure;
}
if ( passwordHandler()->askpass( m_item->workgroup(), m_item->host(),
m_item->share(), state,
kapp->mainWidget() ? kapp->mainWidget() : 0,
"AskPass" ) )
{
// Now we have a password. Retry.
// NOTE: Since the item is appended to the queue, there might
// be the case, that another preview is generated before the
// retry is executed. I think, we can live with that.
preview( m_item );
}
else
{
// The user cancelled the askpass dialog. We won't show an
// error dialog here, but will only clear the contents of
// the preview item and emit the failed() signal.
m_item->clearContents();
emit failed();
}
}
else
{
// OK, error out. We cannot recover from it:
Smb4KError::error( ERROR_GETTING_PREVIEW, QString::null, m_buffer );
m_item->clearContents();
emit failed();
}
}
else if ( list.grep( "Connection to" ).count() != 0 ||
(list.grep( "Error returning browse list:" ).count() != 0 &&
list.grep( "NT_STATUS" ).count() == 0) )
{
// These are errors that we cannot work around. Error out.
Smb4KError::error( ERROR_GETTING_PREVIEW, QString::null, m_buffer );
m_item->clearContents();
emit failed();
}
else
{
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
if ( (*it).stripWhiteSpace().startsWith( "Domain" ) ||
(*it).stripWhiteSpace().startsWith( "OS" ) ||
(*it).stripWhiteSpace().startsWith( "Anonymous" ) )
{
continue;
}
else if ( (*it).contains( "blocks of size" ) != 0 )
{
continue;
}
else
{
QString tmp = (*it).stripWhiteSpace().section( " ", 0, -9 ).stripWhiteSpace();
QString item = tmp.section( " ", 0, -2 ).stripWhiteSpace();
if ( !item.isEmpty() && tmp.section( " ", -1, -1 ).contains( "D" ) != 0 )
{
// We have a directory here.
if ( item.startsWith( "." ) &&
(QString::compare( item.stripWhiteSpace(), "." ) != 0 &&
QString::compare( item.stripWhiteSpace(), ".." ) != 0) )
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::HiddenDirectory, item ) );
}
else
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::Directory, item ) );
}
continue;
}
else if ( item.isEmpty() || tmp.section( " ", -1, -1 ).contains( "D" ) == 0 )
{
// We have a file
if ( item.isEmpty() )
{
if ( tmp.startsWith( "." ) )
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::HiddenFile, tmp ) );
}
else
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::File, tmp ) );
}
}
else
{
if ( item.startsWith( "." ) )
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::HiddenFile, item ) );
}
else
{
m_item->addContents( ContentsItem( Smb4KPreviewItem::File, item ) );
}
}
continue;
}
else
{
continue;
}
}
}
}
emit result( m_item );
QApplication::restoreOverrideCursor();
m_working = false;
emit state( PREVIEWER_STOP );
}
#include "smb4kpreviewer.moc"

@ -0,0 +1,190 @@
/***************************************************************************
smb4kpreviewer - This class queries a remote share for a preview
-------------------
begin : Mo Mai 28 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KPREVIEWER_H
#define SMB4KPREVIEWER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstring.h>
#include <qptrqueue.h>
// KDE includes
#include <kprocess.h>
// forward declarations
class Smb4KPreviewItem;
/**
* This class is part of the core of Smb4K. It queries a remote SMB share for
* a preview and returns the result.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPreviewer : public QObject
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent object
*
* @param name The name of this object
*/
Smb4KPreviewer( QObject *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KPreviewer();
/**
* Get a preview of the contents of @p item.
*
* In the case that @p item represents a 'homes' share, the user will be
* prompted for the user name with which he wants to log in and the share
* name of @p item will be set to the result.
*
* @param item The item for which a preview should be
* requested.
*
* @returns TRUE if einter the share name is not 'homes' or if it could
* successfully be set to a user name. Otherwise it returns FALSE.
*/
bool preview( Smb4KPreviewItem *item );
/**
* Using this function, you can find out whether the previewer is running
* at the moment.
*
* @returns TRUE if the previewer is running or FALSE otherwise.
*/
bool isRunning() { return m_working; }
/**
* Abort any action the previewer is performing at the moment and clear
* the queue.
*/
void abort();
signals:
/**
* Emits the state the previewer is in
*
* @param state The state
*/
void state( int state );
/**
* Emits the preview after the process exited successfully. Get the contents
* of the remote share by looping through the Smb4KPreviewItem::contents() list.
*
* @param item The item for which the preview was received.
*/
void result( Smb4KPreviewItem *item );
/**
* This signal is emitted if an error occurred.
*/
void failed();
protected:
/**
* Reimplemented from QObject
*/
void timerEvent( QTimerEvent *e );
protected slots:
/**
* This slot receives output from stdout.
*
* @param proc The process
*
* @param buf The buffer
*
* @param len The length of the buffer
*/
void slotReceivedStdout( KProcess *proc, char *buf, int len );
/**
* This slot receives output from stderr.
*
* @param proc The process
*
* @param buf The buffer
*
* @param len The length of the buffer
*/
void slotReceivedStderr( KProcess *proc, char *buf, int len );
/**
* Is called, when the KProcess exited.
*
* @param proc The process that exited
*/
void slotProcessExited( KProcess *proc );
private:
/**
* The KProcess object
*/
KProcess *m_proc;
/**
* The output buffer
*/
QString m_buffer;
/**
* This is the pointer to the Smb4KPreviewItem that's
* processed.
*/
Smb4KPreviewItem *m_item;
/**
* Indicates whether the previewer is running or not.
*/
bool m_working;
/**
* This pointer queue holds the pointers to the Smb4KPreviewItem
* objects that are to be processed.
*/
QPtrQueue<Smb4KPreviewItem> m_queue;
/**
* The timer id
*/
int m_timer_id;
};
#endif

@ -0,0 +1,101 @@
/***************************************************************************
smb4kpreviewitem - A container for previews of a remote share
-------------------
begin : Mo Mai 28 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 <ksocketaddress.h>
// application specific includes
#include "smb4kpreviewitem.h"
Smb4KPreviewItem::Smb4KPreviewItem( Smb4KShareItem *item, const QString &ip, const QString &path )
: m_workgroup( item->workgroup() ), m_host( item->host() ), m_share( item->name() ), m_path( path )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
m_location = "//"+m_host+"/"+m_share+"/"+m_path;
}
Smb4KPreviewItem::~Smb4KPreviewItem()
{
}
void Smb4KPreviewItem::setShare( const QString &share )
{
if ( QString::compare( m_share, "homes" ) == 0 )
{
m_share = share;
}
}
void Smb4KPreviewItem::setIP( const QString &ip )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
void Smb4KPreviewItem::setPath( const QString &path )
{
m_path = path;
m_location = "//"+m_host+"/"+m_share+"/"+m_path;
clearContents();
}
void Smb4KPreviewItem::addContents( const ContentsItem &item )
{
// Do not set the last argument to TRUE, because then
// we would be in overwrite mode.
m_contents.append( item );
}
void Smb4KPreviewItem::clearContents()
{
m_contents.clear();
}
bool Smb4KPreviewItem::ipIsValid( const QString &ip )
{
if ( !ip.isEmpty() )
{
KNetwork::KIpAddress ip_address = KNetwork::KIpAddress( ip );
if ( !ip_address.isIPv4Addr() && !ip_address.isIPv6Addr() )
{
return false;
}
}
else
{
return false;
}
return true;
}

@ -0,0 +1,216 @@
/***************************************************************************
smb4kpreviewitem - A container for previews of a remote share
-------------------
begin : Mo Mai 28 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KPREVIEWITEM_H
#define SMB4KPREVIEWITEM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
#include <qmap.h>
#include <qpair.h>
// application specific includes
#include "smb4knetworkitems.h"
typedef QPair<int, QString> ContentsItem;
/**
* This class provides a container for the preview of the contents of a remote
* SMB share.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPreviewItem
{
public:
/**
* The default constructor.
*
* @param item The share for that a preview should be collected.
*
* @param ip The IP address of the host where the share
* is located.
*
* @param path The path for that the preview should be collected.
*/
Smb4KPreviewItem( Smb4KShareItem *item, const QString &ip = QString::null, const QString &path = QString::null );
/**
* The empty constructor.
*/
Smb4KPreviewItem() {}
/**
* The destructor.
*/
~Smb4KPreviewItem();
/**
* Returns the workgroup where the host is located
*/
const QString &workgroup() const { return m_workgroup; }
/**
* Return the name of the host where the share is located.
*/
const QString &host() const { return m_host; }
/**
* Return the name of the share that is to be previewed.
*/
const QString &share() const { return m_share; }
/**
* With this function you can set the share name if this item
* represents a homes share. In all other cases it will do just
* nothing.
*
* @param share The new share name
*/
void setShare( const QString &share );
/**
* Return the path that is to be previewed.
*/
const QString &path() const { return m_path; }
/**
* Returns the IP address of the host where the share
* is located.
*/
const QString &ip() const { return m_ip; }
/**
* Set the IP address of the host.
*
* @param ip The IP address of the host.
*/
void setIP( const QString &ip );
/**
* Set the path for which the preview.
*
* @param path The path
*
* @note As soon as this function is used, the list of files and directories
* will be cleared.
*/
void setPath( const QString &path );
/**
* Returns the current location in the form //HOST/SHARE/PATH.
* It can be used for displaying in a preview dialog or for checks.
*
* @returns The current location
*/
const QString &location() const { return m_location; }
/**
* This enumeration is used for the contents. It determines if
* an item is a file, a hidden file, a directory, or a hidden
* directory.
*/
enum Contents { File, HiddenFile, Directory, HiddenDirectory };
/**
* Returns the contents of the location.
*
* @returns a map of (hidden) files and (hidden) directories.
*/
const QValueList<ContentsItem> &contents() const { return m_contents; }
/**
* Add a file or directory to the contents.
*
* @param item A ContentsItem object. This is a QPair<int,QString>
* with the integer being a value from the Contents
* enumeration and the string being the full path of
* the file or directory.
*
* @see Smb4KPreviewItem::setPath() or Smb4KPreviewItem::clearContents() for how
* the list of files and directories is cleared.
*/
void addContents( const ContentsItem &item );
/**
* Clears the contents.
*/
void clearContents();
private:
/**
* The workgroup of the host
*/
QString m_workgroup;
/**
* The host's name
*/
QString m_host;
/**
* The share name
*/
QString m_share;
/**
* The IP address of the host
*/
QString m_ip;
/**
* The path that has to be previewed.
*/
QString m_path;
/**
* The current location
*/
QString m_location;
/**
* This map stores the contents of the current
* location.
*/
QValueList<ContentsItem> m_contents;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const QString &ip );
};
#endif

@ -0,0 +1,372 @@
/***************************************************************************
smb4kprint - The printing core class.
-------------------
begin : Tue Mar 30 2004
copyright : (C) 2004 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 *
***************************************************************************/
// Qt includes
#include <qtimer.h>
#include <qfile.h>
// KDE includes
#include <kurl.h>
#include <kfileitem.h>
#include <kdebug.h>
// system includes
#include <sys/types.h>
#include <pwd.h>
// application specific includes
#include "smb4kprint.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
#include "smb4kglobal.h"
#include "smb4kauthinfo.h"
#include "smb4kpasswordhandler.h"
#include "smb4kprintinfo.h"
#include "smb4ksettings.h"
using namespace Smb4KGlobal;
Smb4KPrint::Smb4KPrint( QObject *parent, const char *name ) : QObject( parent, name )
{
m_proc = new KProcess( this, "PrintProcess" );
m_proc->setUseShell( true );
m_info = NULL;
m_working = false;
connect( m_proc, SIGNAL( receivedStdout( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStdout( KProcess *, char *, int ) ) );
connect( m_proc, SIGNAL( receivedStderr( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStderr( KProcess *, char *, int ) ) );
connect( m_proc, SIGNAL( processExited( KProcess * ) ),
this, SLOT( slotProcessExited( KProcess * ) ) );
}
Smb4KPrint::~Smb4KPrint()
{
abort();
}
/****************************************************************************
Aborts the current process.
****************************************************************************/
void Smb4KPrint::abort()
{
if ( m_proc->isRunning() )
{
m_proc->kill();
}
}
/****************************************************************************
Start the printing.
****************************************************************************/
bool Smb4KPrint::print( Smb4KPrintInfo *info )
{
// Do nothing if we receive a NULL pointer:
if ( !info )
{
return false;
}
m_working = true;
m_info = info;
// Start processing the file:
if ( QFile::exists( m_info->path() ) )
{
// Determine the mimetype of the file:
KURL url;
url.setPath( m_info->path() );
KFileItem file_item = KFileItem( KFileItem::Unknown, KFileItem::Unknown, url, false );
if ( QString::compare( file_item.mimetype(), "application/postscript" ) == 0 ||
QString::compare( file_item.mimetype(), "application/pdf" ) == 0 ||
file_item.mimetype().startsWith( "image" ) )
{
setDeviceURI();
printNormal();
}
else if ( QString::compare( file_item.mimetype(), "application/x-dvi" ) == 0 &&
!Smb4KSettings::dvips().isEmpty() )
{
setDeviceURI();
printDVI();
}
else if ( (file_item.mimetype().startsWith( "text" ) ||
file_item.mimetype().startsWith( "message" ) ||
QString::compare( file_item.mimetype(), "application/x-shellscript" ) == 0) &&
!Smb4KSettings::enscript().isEmpty() )
{
setDeviceURI();
printText();
}
else
{
Smb4KError::information( INFO_MIMETYPE_NOT_SUPPORTED, file_item.mimetype() );
delete m_info;
m_info = NULL;
m_working = false;
emit state( PRINT_STOP );
return false;
}
}
else
{
Smb4KError::error( ERROR_FILE_NOT_FOUND, m_info->path() );
delete m_info;
m_info = NULL;
m_working = false;
emit state( PRINT_STOP );
return false;
}
return true;
}
/****************************************************************************
Sets the device URI
****************************************************************************/
void Smb4KPrint::setDeviceURI()
{
Smb4KAuthInfo *auth = passwordHandler()->readAuth( new Smb4KAuthInfo( m_info->workgroup(),
m_info->host(), m_info->printer() ) );
QString uri;
// It seems that we must not quote the entries for the DEVICE_URI
// environment variable. Printing will fail if you do it.
if ( !m_info->workgroup().isEmpty() )
{
if ( !auth->user().isEmpty() )
{
uri = QString( "smb://%1:%2@%3/%4/%5" ).arg( auth->user(), auth->password() ).arg( m_info->workgroup(), m_info->host(), m_info->printer() );
}
else
{
uri = QString( "smb://%1/%2/%3" ).arg( m_info->workgroup(), m_info->host(), m_info->printer() );
}
}
else
{
if ( !auth->user().isEmpty() )
{
uri = QString( "smb://%1:%2@%3/%4" ).arg( auth->user(), auth->password() ).arg( m_info->host(), m_info->printer() );
}
else
{
uri = QString( "smb://%1/%2" ).arg( m_info->host(), m_info->printer() );
}
}
m_proc->setEnvironment( "DEVICE_URI", uri );
delete auth;
}
/****************************************************************************
Do normal printing.
****************************************************************************/
void Smb4KPrint::printNormal()
{
QString command;
command.append( "smbspool 111 "+QString( getpwuid( getuid() )->pw_name ) );
command.append( " \"Smb4K print job\" "+QString( "%1" ).arg( m_info->copies() ) );
command.append( " \"\" "+KProcess::quote( m_info->path() ) );
*m_proc << command;
emit state( PRINT_START );
m_proc->start( KProcess::NotifyOnExit, KProcess::AllOutput );
}
/****************************************************************************
Print DVI files.
****************************************************************************/
void Smb4KPrint::printDVI()
{
// The temporary file.
QString temp_file = tempDir()+"/smb4k_print.ps";
QString command;
// First we need the conversion:
command.append( "cd "+KProcess::quote( m_info->path().section( "/", 0, -2 ) )+" && " );
command.append( "dvips -P pdf -o "+temp_file+" "+KProcess::quote( m_info->path().section( "/", -1, -1 ) )+" && " );
// The actual print command:
command.append( "smbspool 111 "+QString( getpwuid( getuid() )->pw_name ) );
command.append( " \"Smb4K print job\" "+QString( "%1" ).arg( m_info->copies() ) );
command.append( " \"\" "+KProcess::quote( temp_file )+" && " );
// Clean up:
command.append( "rm -f "+temp_file );
*m_proc << command;
emit state( PRINT_START );
m_proc->start( KProcess::NotifyOnExit, KProcess::AllOutput );
}
/****************************************************************************
Print text files.
****************************************************************************/
void Smb4KPrint::printText()
{
// The temporary file.
QString temp_file = tempDir()+"/smb4k_print.ps";
QString command;
// Conversion:
command.append( "enscript --columns=1 --no-header --ps-level=2 " );
command.append( "-o "+KProcess::quote( temp_file )+" " );
command.append( KProcess::quote( m_info->path() )+ " && " );
// The actual print command:
command.append( "smbspool 111 "+QString( getpwuid( getuid() )->pw_name ) );
command.append( " \"Smb4K print job\" "+QString( "%1" ).arg( m_info->copies() ) );
command.append( " \"\" "+KProcess::quote( temp_file )+" && " );
// Clean up:
command.append( "rm -f "+temp_file );
*m_proc << command;
emit state( PRINT_START );
m_proc->start( KProcess::NotifyOnExit, KProcess::AllOutput );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KPrint::slotReceivedStdout( KProcess *, char *buf, int len )
{
m_buffer.append( QString::fromLocal8Bit( buf, len ) );
}
void Smb4KPrint::slotReceivedStderr( KProcess *, char *buf, int len )
{
m_buffer.append( QString::fromLocal8Bit( buf, len ) );
if ( m_buffer.contains( "NT_STATUS" ) != 0 )
{
abort();
}
}
void Smb4KPrint::slotProcessExited( KProcess * )
{
bool retry = false;
if ( m_buffer.contains( "NT_STATUS", true ) != 0 ||
m_buffer.contains( "enscript", true ) != 0 ||
m_buffer.contains( "dvips", true ) != 0 )
{
if ( m_buffer.contains( "NT_STATUS_ACCESS_DENIED" ) != 0 || m_buffer.contains( "NT_STATUS_LOGON_FAILURE" ) != 0 )
{
int state = Smb4KPasswordHandler::None;
if ( m_buffer.contains( "NT_STATUS_ACCESS_DENIED" ) != 0 )
{
state = Smb4KPasswordHandler::AccessDenied;
}
else if (m_buffer.contains( "NT_STATUS_LOGON_FAILURE" ) != 0 )
{
state = Smb4KPasswordHandler::LogonFailure;
}
if ( passwordHandler()->askpass( m_info->workgroup(), m_info->host(), m_info->printer(), state ) )
{
retry = true;
QTimer::singleShot( 50, this, SLOT( slotRetry() ) );
}
}
else
{
Smb4KError::error( ERROR_PRINTING, m_info->path(), m_buffer );
// Clean up:
QFile::remove( QString( "%1/smb4k_print.ps" ).arg( tempDir() ) );
}
}
else
{
// Clean up:
QFile::remove( QString( "%1/smb4k_print.ps" ).arg( tempDir() ) );
}
m_proc->clearArguments();
if ( !retry )
{
delete m_info;
m_info = NULL;
}
m_working = false;
emit state( PRINT_STOP );
}
void Smb4KPrint::slotRetry()
{
print( m_info );
}
#include "smb4kprint.moc"

@ -0,0 +1,170 @@
/***************************************************************************
smb4kprint - The printing core class.
-------------------
begin : Tue Mar 30 2004
copyright : (C) 2004 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 *
***************************************************************************/
#ifndef SMB4KPRINT_H
#define SMB4KPRINT_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstring.h>
#include <qwidget.h>
// KDE includes
#include <kprocess.h>
#include <kdialogbase.h>
// forward declarations
class Smb4KPrintInfo;
/**
* This is a core class. It provides the interface for printing documents over
* the network neighborhood.
*
* You shouldn't use this class directly but access it through Smb4KCore.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPrint : public QObject
{
Q_OBJECT
public:
/**
* The constructor.
*/
Smb4KPrint( QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KPrint();
/**
* This function starts the printing of a file. It takes a Smb4KPrintInfo object
* and constructs the print dialog from it. The information entered there will be
* used to print the file.
*
* Note that @p info will be deleted. So do not try to use the pointer later in your
* code!
*
* @param info The Smb4KShareItem object
*/
bool print( Smb4KPrintInfo *info );
/**
* Aborts the print process.
*/
void abort();
/**
* This function returns TRUE if the printer handler is running and
* FALSE otherwise.
*
* @returns TRUE is the printer handler is running and FALSE otherwise.
*/
bool isRunning() { return m_working; }
signals:
/**
* This signal emits the run state.
*
* @param state The so-called run state. There are several defined
* in the smb4kdefs.h header file.
*/
void state( int state );
protected slots:
/**
* This slot receives output at stdout.
*/
void slotReceivedStdout( KProcess *, char *buf, int len );
/**
* This slot receives output at stderr.
*/
void slotReceivedStderr( KProcess *, char *buf, int len );
/**
* This slot is called when the process exited.
*/
void slotProcessExited( KProcess * );
/**
* This slot is invoked if the print process should be restarted
* (i.e. because authentication data was missing, etc.).
*/
void slotRetry();
private:
/**
* The KProcess object.
*/
KProcess *m_proc;
/**
* The buffer
*/
QString m_buffer;
/**
* This boolean is TRUE if the printer handler is running and
* FALSE otherwise.
*/
bool m_working;
/**
* The print info object
*/
Smb4KPrintInfo *m_info;
/**
* Sets the device URI
*/
void setDeviceURI();
/**
* Do normal printing.
*/
void printNormal();
/**
* Print DVI files.
*/
void printDVI();
/**
* Print text files
*/
void printText();
};
#endif

@ -0,0 +1,76 @@
/***************************************************************************
smb4kprintinfo - description
-------------------
begin : Mo Apr 19 2004
copyright : (C) 2004 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 <ksocketaddress.h>
// application specific includes
#include "smb4kprintinfo.h"
Smb4KPrintInfo::Smb4KPrintInfo( Smb4KShareItem *item, const QString &ip, const QString &path, int copies )
: m_workgroup( item->workgroup() ), m_host( item->host() ), m_printer( item->name() ), m_path( path ),
m_copies( copies ), m_comment( item->comment() )
{
m_ip = ipIsValid( ip ) ? ip : QString::null;
}
Smb4KPrintInfo::~Smb4KPrintInfo()
{
}
void Smb4KPrintInfo::setPath( const QString &path )
{
m_path = path;
}
void Smb4KPrintInfo::setCopies( int num )
{
m_copies = num;
}
bool Smb4KPrintInfo::ipIsValid( const QString &ip )
{
if ( !ip.isEmpty() )
{
KNetwork::KIpAddress ip_address = KNetwork::KIpAddress( ip );
if ( !ip_address.isIPv4Addr() && !ip_address.isIPv6Addr() )
{
return false;
}
}
else
{
return false;
}
return true;
}

@ -0,0 +1,147 @@
/***************************************************************************
smb4kprintinfo - description
-------------------
begin : Mo Apr 19 2004
copyright : (C) 2004 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 *
***************************************************************************/
#ifndef SMB4KPRINTINFO_H
#define SMB4KPRINTINFO_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
// application specific includes
#include "smb4knetworkitems.h"
/**
* This class provides a container that holds all the info
* that is needed to print a file.
*/
class Smb4KPrintInfo
{
public:
/**
* The constructor.
*
* @param item The Smb4KShareItem that represents the printer
*
* @param ip The IP address of the host
*
* @param filepath The path of the file to print
*
* @param copies The number of copies
*/
Smb4KPrintInfo( Smb4KShareItem *item, const QString &ip, const QString &filepath = QString::null, int copies = 1 );
/**
* Empty constructor.
*/
Smb4KPrintInfo() {}
/**
* The destructor.
*/
~Smb4KPrintInfo();
/**
* Returns the path of the file.
*/
const QString &path() const { return m_path; }
/**
* Returns the host where the printer is located.
*/
const QString &host() const { return m_host; }
/**
* Returns the workgroup in which the host located.
*/
const QString &workgroup() const { return m_workgroup; }
/**
* Returns the name of the printer.
*/
const QString &printer() const { return m_printer; }
/**
* Returns the IP address of the host.
*/
const QString &ip() const { return m_ip; }
/**
* Sets the path to the file to print.
*/
void setPath( const QString &path );
/**
* Returns the number of copies the user wants to have.
*/
int copies() const { return m_copies; }
/**
* Sets the number of copies.
*/
void setCopies( int num );
/**
* Returns the comment.
*/
const QString &comment() const { return m_comment; }
private:
/**
* The workgroup.
*/
QString m_workgroup;
/**
* The host.
*/
QString m_host;
/**
* The IP address.
*/
QString m_ip;
/**
* The printer name.
*/
QString m_printer;
/**
* The path to the file to print.
*/
QString m_path;
/**
* Holds the number of copies the user wants to have.
*/
int m_copies;
/**
* The comment
*/
QString m_comment;
/**
* This function checks if the IP address is valid, i.e. the
* IP address is either IP v4 or IP v6. It returns either TRUE
* or FALSE.
*
* @param ip The IP address that's going to be checked.
*
* @returns TRUE if the IP address is valid and FALSE otherwise.
*/
bool ipIsValid( const QString &ip );
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,253 @@
/***************************************************************************
smb4ksambaoptionshandler - This class handles the Samba options.
-------------------
begin : So Mai 14 2006
copyright : (C) 2006-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSAMBAOPTIONSHANDLER_H
#define SMB4KSAMBAOPTIONSHANDLER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qmap.h>
// KDE includes
#include <kconfig.h>
// forward declarations
class Smb4KSambaOptionsInfo;
class Smb4KShare;
/**
* This class belongs to the core classes of Smb4K and handles the global
* and the custom Samba options.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KSambaOptionsHandler : public QObject
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent object
*
* @param name The name of this object
*/
Smb4KSambaOptionsHandler( QObject *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KSambaOptionsHandler();
/**
* Retrieve the list of shares that have custom options defined.
* You will not only get those options that have different ports etc.
* defined but also all shares that are to be remounted.
*
* @returns the list of all shares that have custom options defined.
*/
const QValueList<Smb4KSambaOptionsInfo *> &customOptionsList();
/**
* This functions sets the remount flag of the share @p share to TRUE or FALSE.
* In case the share is not yet in the list of shares that are to be remounted,
* it will be added. If you set the remount flag to FALSE on an existing entry,
* it will stay in the list even if no other custom options were defined.
*
* @param share The Smb4KShare object that represents the share
*
* @param yes TRUE if you want the share to be remounted and FALSE
* otherwise
*/
void remount( Smb4KShare *share, bool yes );
/**
* Commit the whole list of shares with custom options to the configuration
* file. You should call this if you exit the application.
*/
void sync();
/**
* This function returns the line of arguments for the 'smbclient' program.
* The arguments are spcific to the share that is defined by @p share. You have
* to provide the name of the shares - as always - in the form //HOST/SHARE.
*
* @param share The name of the share.
*
* @returns a list of arguments for use with the 'smbclient' program.
*/
const QString smbclientOptions( const QString &share = QString::null );
/**
* This function returns the "global" options for nmblookup, i.e. the domain
* the client is in, if Kerberos should be used, etc.
*
* @param with_broadcast Return the global broadcast address if defined.
*
* @returns a string with the "global" options for nmblookup
*/
const QString nmblookupOptions( bool with_broadcast = true );
/**
* This function returns the options defined in the global section of the smb.conf
* file. All option names have been converted to lower case and you can find each
* entry by providing the option name in lowercase (!) as key.
*
* @returns a list of the options defined in smb.conf.
*/
const QMap<QString,QString> &globalSambaOptions();
/**
* This function returns the WINS server the system is using.
*
* @returns the name or IP of the WINS server
*/
const QString &winsServer();
/**
* This enumeration is for use with the netOptions() function. It tells which
* command to use.
*/
enum NetCommand { Share, ServerDomain, LookupHost, LookupMaster, Domain };
/**
* This function returns the options for the net command.
*
* @param command One of the entries of the NetCommand enumeration.
*
* @param networkItem The name of the network Item. May be empty.
*
* @param protocol Force a certain protocol (rap/rpc/ads) to be used.
*
* @returns the list of arguments for the net command or QString::null if an error occurred.
*/
const QString netOptions( int command, const QString &networkItem, const QString &protocol = QString::null );
/**
* This function returns the options for smbmount/mount.cifs under Linux
* and similar operating systems or for mount_smbfs under FreeBSD.
*
* Note: Under Linux etc. this is a comma-separated list which ends with
* a comma, so remember this when you build up the command line.
*
* @param share The share that is to be mounted.
*/
const QString mountOptions( const QString &share );
/**
* Find a network item in the list.
*
* Please note that if the host where a share you are probing for
* is located, a pointer to this *host* item will be returned unless
* you set @p exactMatch to TRUE in which case NULL is returned! If
* neither the host nor the share is found, NULL is returned.
*
* @param item The name of the network item to find.
*
* @param exactMatch The name has to match exactly the result that's returned.
*
* @returns the network item.
*/
Smb4KSambaOptionsInfo *findItem( const QString &item, bool exactMatch = false ) { return find_item( item, exactMatch ); }
/**
* Add a new Smb4KSambaOptionsInfo object to the list of custom options. If the item already exists,
* the old options will be replaced by the new ones.
*
* @param info The Smb4KSambaOptionsInfo object
*
* @param sync If TRUE, the list is sync'ed with the config file.
*/
void addItem( Smb4KSambaOptionsInfo *info, bool sync );
/**
* Remove an item from the list.
*
* @param name The name of the item.
*
* @param sync If TRUE, the list is sync'ed with the config file.
*/
void removeItem( const QString &name, bool sync );
private:
/**
* The list of network items that have custom options defined.
*/
QValueList<Smb4KSambaOptionsInfo *> m_list;
/**
* This function reads the options from the config file.
*/
void read_options();
/**
* Write the list of custom shares to the file.
*/
void write_options();
/**
* This function searches a particular network item in the list. If this item is a share
* and it is not found, @p exactMatch determines if NULL is returned or if the values of
* the item that matches @p item closest (i.e. the host, or another share that's located
* on the host). In most cases you want @p exactMatch to be FALSE.
* Please note: Do not delete the pointer that's returned by this function or you will
* remove an item from the list!
*
* @param item The name of the network item.
*
* @param exactMatch The name has to match exactly the result that's returned.
*
* @returns The Smb4KSambaOptionsInfo object associated with the network item.
*/
Smb4KSambaOptionsInfo *find_item( const QString &item, bool exactMatch = false );
/**
* This function reads the entries of the global section of Samba's configuration
* file smb.conf and puts them into a map.
*/
void read_smb_conf();
/**
* This map carries the options defined in the [global] section of Samba's configuration
* file smb.conf. You can access a certain value by providing the lower case option name
* as key.
*/
QMap<QString,QString> m_samba_options;
/**
* The WINS server
*/
QString m_wins_server;
};
#endif

@ -0,0 +1,137 @@
/***************************************************************************
smb4ksambaoptionsinfo - This is a container class that carries
various information of extra options for a specific host.
-------------------
begin : Mi Okt 18 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 *
***************************************************************************/
// application specific includes
#include "smb4ksambaoptionsinfo.h"
#include "smb4kshare.h"
Smb4KSambaOptionsInfo::Smb4KSambaOptionsInfo( const QString &name )
: m_name( name ), m_remount( false ), m_port( -1 ),
#ifndef __FreeBSD__
m_filesystem( QString::null ), m_write_access( true ),
#endif
m_protocol( QString::null ), m_kerberos( false ),
m_uid( QString::null ), m_gid( QString::null )
{
}
Smb4KSambaOptionsInfo::Smb4KSambaOptionsInfo( Smb4KShare *share )
: m_name( share->name() ), m_remount( false ), m_port( -1 ),
#ifndef __FreeBSD__
m_filesystem( share->filesystem() ), m_write_access( true ),
#endif
m_protocol( QString::null ), m_kerberos( false ),
m_uid( QString( "%1" ).arg( share->uid() ) ), m_gid( QString( "%1" ).arg( share->gid() ) )
{
}
Smb4KSambaOptionsInfo::Smb4KSambaOptionsInfo( const Smb4KSambaOptionsInfo &info )
: m_name( info.itemName() ), m_remount( info.remount() ), m_port( info.port() ),
#ifndef __FreeBSD__
m_filesystem( info.filesystem() ), m_write_access( info.writeAccess() ),
#endif
m_protocol( info.protocol() ), m_kerberos( info.kerberos() ),
m_uid( info.uid() ), m_gid( info.gid() )
{
}
Smb4KSambaOptionsInfo::~Smb4KSambaOptionsInfo()
{
}
void Smb4KSambaOptionsInfo::setRemount( bool rm )
{
m_remount = rm;
}
void Smb4KSambaOptionsInfo::setItemName( const QString &name )
{
m_name = name;
}
void Smb4KSambaOptionsInfo::setPort( int port )
{
m_port = port;
}
void Smb4KSambaOptionsInfo::setProtocol( const QString &p )
{
if ( QString::compare( p, "auto" ) != 0 )
{
m_protocol = p;
}
else
{
m_protocol = QString::null;
}
}
void Smb4KSambaOptionsInfo::setKerberos( bool krb )
{
m_kerberos = krb;
}
int Smb4KSambaOptionsInfo::type()
{
return m_name.contains( "/" ) == 3 ? Share : Host;
}
void Smb4KSambaOptionsInfo::setUID( const QString &uid )
{
m_uid = uid;
}
void Smb4KSambaOptionsInfo::setGID( const QString &gid )
{
m_gid = gid;
}
#ifndef __FreeBSD__
void Smb4KSambaOptionsInfo::setFilesystem( const QString &fs )
{
m_filesystem = fs;
}
void Smb4KSambaOptionsInfo::setWriteAccess( bool rw )
{
m_write_access = rw;
}
#endif

@ -0,0 +1,291 @@
/***************************************************************************
smb4ksambaoptionsinfo - This is a container class that carries
various information of extra options for a specific host.
-------------------
begin : Mi Okt 18 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 *
***************************************************************************/
#ifndef SMB4KSAMBAOPTIONSINFO_H
#define SMB4KSAMBAOPTIONSINFO_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
// forward declarations
class Smb4KShare;
/**
* This class provides a container for all extra options that the user defined
* for a certain share.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KSambaOptionsInfo
{
public:
/**
* Constructor. It takes the name of the network item in the form
* HOST or //HOST/SHARE as only argument. If you use this constructor, you
* need to use the set* functions to add information.
*
* @param name The network item's name.
*/
Smb4KSambaOptionsInfo( const QString &name );
/**
* Constructor. It takes a Smb4KShare object and extracts the name and the
* filesystem from it. All other information has to be set with the set*
* functions.
*
* @param share A Smb4KShare object representing a share.
*/
Smb4KSambaOptionsInfo( Smb4KShare *share );
/**
* The copy constructor.
*
* @param info A Smb4KShareOptionsInfo object
*/
Smb4KSambaOptionsInfo( const Smb4KSambaOptionsInfo &info );
/**
* The destructor.
*/
~Smb4KSambaOptionsInfo();
/**
* Sets the "should be remounted" flag.
*
* @param rm TRUE if the share is to be remounted and
* FALSE otherwise.
*/
void setRemount( bool rm );
/**
* Returns TRUE if the share is to be remounted and FALSE otherwise.
*
* @returns TRUE if the share is to be remounted and FALSE otherwise
*/
bool remount() const { return m_remount; }
/**
* This function sets the item name.
*
* @param name The name of the network item
*/
void setItemName( const QString &name );
/**
* This function returns the name of the network item, i.e. the server or
* share.
*
* @returns the name of the network item.
*/
const QString &itemName() const { return m_name; }
/**
* This function sets the port that should be used when querying this share.
*
* @param port The port number
*/
void setPort( int port );
/**
* This function returns the port that should be used when working with this
* share. Please note, that it will be returned as an integer. If no port has been
* defined, -1 will be returned.
*
* @returns the port number
*/
int port() const { return m_port; }
/**
* This function sets the protocol to use with the net command. If @p protocol
* is equal to "auto", the protocol will automatically be set to "" internally,
* so that Smb4KSambaOptionsInfo::protocol() returns an empty string.
*
* @param protocol the protocol
*/
void setProtocol( const QString &protocol );
/**
* This function returns the protocol to use with the net command.
*
* @retuns the protocol
*/
const QString &protocol() const { return m_protocol; }
/**
* Set the 'Use Kerberos' flag.
*
* @param krb TRUE if the user wants to use Kerberos
* and FALSE otherwise.
*/
void setKerberos( bool krb );
/**
* This functions returns TRUE if the user wants to use Kerberos and
* otherwise it returns FALSE.
*
* @returns TRUE if Kerberos should be used and FALSE
* otherwise.
*/
bool kerberos() const { return m_kerberos; }
/**
* With this function you can set the UID you want to use for this item.
* However, it makes only sense with shares.
*
* @param uid The UID
*/
void setUID( const QString &uid );
/**
* This functions returns the UID defined for this item.
*
* @returns the UID.
*/
const QString &uid() const { return m_uid; }
/**
* With this function you can set the GID you want to use for this item.
* However, it makes only sense with shares.
*
* @param gid The GID
*/
void setGID( const QString &gid );
/**
* This functions returns the GID defined for this item.
*
* @returns the GID.
*/
const QString &gid() const { return m_gid; }
/**
* This function returns the type of the network item for which the options
* have been defined.
*
* @returns the type according to the Type enumeration.
*/
int type();
/**
* The Type enumeration.
*/
enum Type { Share, Host };
#ifndef __FreeBSD__
/**
* This function sets the file system that is to be used when mounting the share.
*
* Note: This function is not available und FreeBSD.
*
* @param fs the file system name
*/
void setFilesystem( const QString &fs );
/**
* This function returns the file system that is to be used.
*
* Note: This function is not available und FreeBSD.
*
* @returns the file system name
*/
const QString &filesystem() const { return m_filesystem; }
/**
* Set if the share is to be mounted read-write or read-only.
*
* Note: This function is not available und FreeBSD.
*
* @param rw TRUE if read-write and FALSE otherwise.
*/
void setWriteAccess( bool rw );
/**
* This functions returns TRUE if the user wants to mount a share read-write
* otherwise it returns FALSE.
*
* Note: This function is not available und FreeBSD.
*
* @returns TRUE if read-write and FALSE otherwise.
*/
bool writeAccess() const { return m_write_access; }
#endif
private:
/**
* The share name.
*/
QString m_name;
/**
* Should be remounted?
*/
bool m_remount;
/**
* The port number
*/
int m_port;
#ifndef __FreeBSD__
/**
* The file system
*/
QString m_filesystem;
/**
* Mount read-write or read-only?
*/
bool m_write_access;
#endif
/**
* The protocol
*/
QString m_protocol;
/**
* Use Kerberos or not
*/
bool m_kerberos;
/**
* The UID
*/
QString m_uid;
/**
* The GID
*/
QString m_gid;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,485 @@
/***************************************************************************
smb4kscanner.h - The network scan core class of Smb4K.
-------------------
begin : Sam Mai 31 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSCANNER_H
#define SMB4KSCANNER_H
#ifndef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qobject.h>
#include <qstringlist.h>
#include <qptrqueue.h>
// KDE includes
#include <kprocess.h>
// application specific includes
#include "smb4kdefs.h"
// forward declarations
class Smb4KScannerPrivate;
class Smb4KWorkgroupItem;
class Smb4KHostItem;
class Smb4KShareItem;
/**
* This is the core class, that communicates with the network. All look-up
* stuff is done here.
*
* @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
*/
class Smb4KScanner : public QObject
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param workgroups A list of Smb4KWorkgroupItem items which will be filled by the scanner
* with the list of available workgroups. If a NULL pointer is passed, a
* private list will be created which cannot be accessed from outside.
*
* @param hosts A list of Smb4KHostItem items which will be filled by the scanner.
* with the list of available hosts. If a NULL pointer is passed, a
* private list will be created which cannot be accessed from outside.
*
* @param parent The parent of this class.
*
* @param name The name of this class.
*/
Smb4KScanner( QValueList<Smb4KWorkgroupItem *> *workgroups = 0,
QValueList<Smb4KHostItem *> *hosts = 0,
QObject *parent = 0,
const char *name = 0 );
/**
* The destructor.
*/
~Smb4KScanner();
/**
* Initiates a network scan.
*
* Please not that after having invoked this function, the list of workgroups
* as well as the list of known hosts will be cleared and refilled. Thus, all
* known hosts except the current workgroup master browsers will have been
* vanished.
*/
void rescan();
/**
* Aborts the network scan.
*/
void abort();
/**
* Reads the options.
*/
void readOptions();
/**
* Scan for the shares on a selected host.
*
* @param workgroup The workgroup of the host you want to scan.
*
* @param host The host you want to scan.
*
* @param ip The IP address of the host.
*
* @param protocol With this argument you can force a special protocol
* the net command has to use. Normally, you do not have
* to set here anything.
*/
void getShares( const QString &workgroup,
const QString &host,
const QString &ip,
const QString &protocol = QString::null );
/**
* Scans for workgroup members.
*
* @param workgroup The workgroup of the master browser that should be scanned.
*
* @param master The name of the master browser.
*
* @param ip The IP address of the master browser.
*/
void getWorkgroupMembers( const QString &workgroup,
const QString &master,
const QString &ip );
/**
* Get more info about a share (i.e. server and OS string, etc.).
*
* @param workgroup The workgroup of the host
*
* @param host The host's name
*
* @param ip The host's IP address
*/
void getInfo( const QString &workgroup,
const QString &host,
const QString &ip );
/**
* Starts the search for a host that matches @p string. If the host is already
* in the list of known hosts, this function immediately emits the searchResult()
* signal with the Smb4KHostItem representing the host. If this is not the case,
* a search process is started.
*
* @param string The user supplied search string.
*/
void search( const QString &string );
/**
* This function returns an Smb4KWorkgroupItem, if the the workgroup
* exists in the list, or NULL, if it does not.
*
* @param workgroup The name of the workgroup
*/
Smb4KWorkgroupItem *getWorkgroup( const QString &workgroup );
/**
* This function reports if the scanner is running or not.
*
* @returns TRUE if the scanner is running and FALSE otherwise.
*/
bool isRunning() { return m_working; }
/**
* This function returns the specified host item, or NULL, if this host was not found.
* The name of the host is mandatory. The workgroup may be empty, but should be given,
* because this will speed up the search process.
*
* @param name The name of the host
*
* @param workgroup The workgroup of the host item
*
* @returns A host item
*/
Smb4KHostItem *getHost( const QString &name,
const QString &workgroup = QString::null );
/**
* This function inserts a @p host into the list of known servers. If it belongs to
* a workgroup that was not known until now, a new Smb4KWorkgroupItem item is also
* created and added to the list of known workgroups. @p host is then marked as
* pseudo master browser. On success, the this function emits the hostAdded() and
* hostListChanged() signals. If the host is already in the known, nothing is done.
*
* @param host The host that should be inserted
*/
void insertHost( Smb4KHostItem *host );
/**
* This function initializes the network scan It just executes the rescan() function,
* so you can also use that instead.
*/
void init();
signals:
/**
* This signal emits the run state.
*
* @param state The so-called run state. There are several defined
* in the smb4kdefs.h header file.
*/
void state( int state );
/**
* This signal is emitted, when the workgroup list has been updated.
*
* @param list The list of workgroups in the network neighborhood.
*/
void workgroups( const QValueList<Smb4KWorkgroupItem *> &list );
/**
* Emits the list of workgroup members.
*
* @param workgroup The workgroup in which the members are located
*
* @param list The list of workgroup members.
*/
void members( const QString &workgroup, const QValueList<Smb4KHostItem *> &list );
/**
* Emits the list of shares.
*
* @param host The host that carries the shares
*
* @param list The list of shares
*/
void shares( const QString &host, const QValueList<Smb4KShareItem *> &list );
/**
* This signal provides info about a certain host. It passes the server
* and the OS string.
*/
void info( Smb4KHostItem *host );
/**
* Is emitted, when the results of a network search are to be passed.
*/
void searchResult( Smb4KHostItem *host );
/**
* This signal emits the host item for which an IP address has
* been found.
*
* @param host The host item with the new IP address
*/
void ipAddress( Smb4KHostItem *host );
/**
* This signal is emitted when the list of hosts is changed.
*/
void hostListChanged();
/**
* This signal is emitted if a request could not be processed
* successfully.
*/
void failed();
/**
* This signal is emitted when a host has been added to the list of known
* hosts via the addHost() function.
*
* @param host The Smb4KHostItem that represents the host that
* was added.
*/
void hostAdded( Smb4KHostItem *host );
protected:
/**
* Starts the process.
*
* @param state The state
*/
void startProcess( int state );
/**
* Is called, when the main process ends.
*/
void endProcess();
/**
* Processes the output of the network group scan.
*/
void processWorkgroups();
/**
* Processes the list of workgroup members retrieved by
* scanning the workgroup master browser.
*/
void processWorkgroupMembers();
/**
* Processes the output of the host scan.
*/
void processShares();
/**
* Processes the output of the scan for the OS and Server
* string.
*/
void processInfo();
/**
* Processes the output of a search request.
*/
void processSearch();
/**
* Process the data from the IP range scan.
*/
void processIPScan();
/**
* Reimplemented from QObject
*/
void timerEvent( QTimerEvent *e );
protected slots:
/**
* Is called, if something is received on stdout from the main process.
*
* @param proc The process
*
* @param buf The buffer
*
* @param len The length of the buffer
*/
void slotReceivedStdout( KProcess *proc,
char *buf,
int len );
/**
* Is called, when the KProcess exited.
*
* @param proc The process that exited
*/
void slotProcessExited( KProcess *proc );
/**
* Is called, if something is received on stderr from the main process.
*
* @param proc The process
*
* @param buf The buffer
*
* @param len The length of the buffer
*/
void slotReceivedStderr( KProcess *proc,
char *buf,
int len );
/**
* Is called when the scan for IP addresses produced output on stdout.
*
* @param proc The process
*
* @param buf The buffer
*
* @param len The length of the buffer
*/
void slotReceivedIPAddresses( KProcess *proc,
char *buf,
int len );
/**
* Is called, when the KProcess exited.
*
* @param proc The process that exited
*/
void slotIPAddressProcessExited( KProcess *proc );
private:
/**
* Initiates the (re-)scan of the network to retrieve the initial
* browse list.
*/
void scanNetwork();
/**
* Scans the group master for the group members.
*/
void scanForWorkgroupMembers( const QString &workgroup,
const QString &master,
const QString &ip );
/**
* Scans the chosen host for its shares. This is the private part
* of @see Smb4KScanner::getShares().
*/
void scanForShares( const QString &workgroup,
const QString &host,
const QString &ip,
const QString &protocol );
/**
* Scans a given host for its OS and Server string.
*/
void scanForInfo( const QString &workgroup,
const QString &host,
const QString &ip );
/**
* Searches for a given host.
*/
void searchForHost( const QString &host );
/**
* This function initializes the lookup of IP addresses.
*/
void lookupIPAddresses();
/**
* This function takes an Smb4KWorkgroupItem and appends it to the list,
* if the represented workgroup isn't already in it.
*/
void appendWorkgroup( Smb4KWorkgroupItem *item );
/**
* Internal enumeration.
*/
enum TODO{ Workgroups, QueryHost, IPScan, Hosts, Shares, Info, Search, Init, Idle };
/**
* The main KProcess object.
*/
KProcess *m_proc;
/**
* The buffer for the main process.
*/
QString m_buffer;
/**
* This queue stores the incoming requests until they are processed.
*/
QPtrQueue<QString> m_queue;
/**
* Is set to true, if the scanner is running.
*/
bool m_working;
/**
* The list of workgroups including the master browser and their
* IP addresses.
*/
QValueList<Smb4KWorkgroupItem *> *m_workgroups_list;
/**
* This list contains all hosts, that are found by the scanner and
* that are currently active.
*/
QValueList<Smb4KHostItem *> *m_hosts_list;
/**
* The internal state of the main process. Do not mix this up with
* the state that's emitted to notify the application about changes.
*/
int m_state;
/**
* This is the pointer to the private helper class.
*/
Smb4KScannerPrivate *m_priv;
/**
* The timer id
*/
int m_timer_id;
};
#endif

@ -0,0 +1,96 @@
/***************************************************************************
smb4kscanner_p - This is a private helper class for Smb4KScanner.
-------------------
begin : Do Jul 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// application specific includes
#include "smb4kscanner_p.h"
Smb4KScannerPrivate::Smb4KScannerPrivate()
{
retry = false;
clearData();
}
Smb4KScannerPrivate::~Smb4KScannerPrivate()
{
}
void Smb4KScannerPrivate::clearData()
{
m_workgroup = QString::null;
m_host = QString::null;
m_ip = QString::null;
m_share = QString::null;
}
void Smb4KScannerPrivate::setWorkgroup( const QString &w )
{
m_workgroup = w;
}
void Smb4KScannerPrivate::setHost( const QString &h )
{
m_host = h;
}
void Smb4KScannerPrivate::setIP( const QString &i )
{
m_ip = i;
}
void Smb4KScannerPrivate::setShare( const QString &s )
{
m_share = s;
}
const QString &Smb4KScannerPrivate::workgroup()
{
return m_workgroup;
}
const QString &Smb4KScannerPrivate::host()
{
return m_host;
}
const QString &Smb4KScannerPrivate::ip()
{
return m_ip;
}
const QString &Smb4KScannerPrivate::share()
{
return m_share;
}

@ -0,0 +1,59 @@
/***************************************************************************
smb4kscanner_p - This is a private helper class for Smb4KScanner.
-------------------
begin : Do Jul 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSCANNER_P_H
#define SMB4KSCANNER_P_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
class Smb4KScannerPrivate
{
public:
Smb4KScannerPrivate();
~Smb4KScannerPrivate();
bool retry;
void clearData();
void setWorkgroup( const QString &w );
void setHost( const QString &h );
void setIP( const QString &i );
void setShare( const QString &s );
const QString &workgroup();
const QString &host();
const QString &ip();
const QString &share();
private:
QString m_workgroup;
QString m_host;
QString m_ip;
QString m_share;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,6 @@
File=smb4k.kcfg
ClassName=Smb4KSettings
Singleton=true
Mutators=true
ItemAccessors=true
SetUserTexts=true

@ -0,0 +1,216 @@
/***************************************************************************
smb4kshare - This is a container that holds information about
a mounted remote share.
-------------------
begin : Do Mär 4 2004
copyright : (C) 2004 by Franck Babin
(C) 2005 by Alexander Reinholdt
email : babinfranck@yahoo.ca
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 *
***************************************************************************/
// Qt includes
#include <qdir.h>
// KDE includes
#include <kdebug.h>
// system includes
#include <unistd.h>
#include <sys/types.h>
// application specific includes
#include "smb4kshare.h"
Smb4KShare::Smb4KShare( const QString &name, const QString &path, const QString &filesystem, const int uid, const int gid, bool broken ) :
m_name(name), m_path( path.local8Bit() ), m_filesystem( filesystem ), m_user( uid ), m_group( gid ), m_cifs_login( QString::null ), m_broken( broken ), m_total( 0 ), m_free( 0 )
{
//FIXME should throw an exception if one of the param is empty
if ( uid != (int)getuid() && gid != (int)getgid() )
{
m_foreign_mount = true;
}
else
{
m_foreign_mount = false;
}
}
Smb4KShare::Smb4KShare( const QString &name, const QString &path, const QString &filesystem, const QString &username, bool foreign, bool broken ) :
m_name( name ), m_path( path.local8Bit() ), m_filesystem( filesystem ), m_user( (int)getuid() ), m_group( (int)getgid() ), m_cifs_login( username ), m_foreign_mount( foreign ), m_broken( broken ), m_total( 0 ), m_free( 0 )
{
}
Smb4KShare::Smb4KShare( const Smb4KShare &s ) :
m_name( s.name() ), m_path( s.path() ), m_filesystem( s.filesystem() ), m_user( s.uid() ), m_group( s.gid() ), m_cifs_login( s.cifsLogin() ), m_foreign_mount( s.isForeign() ), m_broken( s.isBroken() ), m_total( s.totalDiskSpace() ), m_free( s.freeDiskSpace() )
{
}
Smb4KShare::~Smb4KShare()
{
}
const QString &Smb4KShare::name() const
{
return m_name;
}
const QCString &Smb4KShare::path() const
{
return m_path;
}
const QCString Smb4KShare::canonicalPath() const
{
return m_broken ? m_path : QDir( m_path ).canonicalPath().local8Bit();
}
int Smb4KShare::uid() const
{
return (int)m_user.uid();
}
void Smb4KShare::setUID( int uid )
{
m_user = KUser( uid );
}
int Smb4KShare::gid() const
{
return (int)m_group.gid();
}
void Smb4KShare::setGID( int gid )
{
m_group = KUserGroup( gid );
}
const QString Smb4KShare::user() const
{
return m_user.loginName();
}
const QString Smb4KShare::group() const
{
return m_group.name();
}
const QString &Smb4KShare::filesystem() const
{
return m_filesystem;
}
const QString &Smb4KShare::cifsLogin() const
{
return m_cifs_login;
}
bool Smb4KShare::isForeign() const
{
return m_foreign_mount;
}
void Smb4KShare::setForeign( bool foreign )
{
m_foreign_mount = foreign;
}
bool Smb4KShare::isBroken() const
{
return m_broken;
}
void Smb4KShare::setBroken( bool broken )
{
m_broken = broken;
}
void Smb4KShare::setTotalDiskSpace( double total )
{
m_total = total;
}
void Smb4KShare::setFreeDiskSpace( double free )
{
m_free = free;
}
double Smb4KShare::totalDiskSpace() const
{
return m_total;
}
double Smb4KShare::freeDiskSpace() const
{
return m_free;
}
double Smb4KShare::percentage() const
{
return (m_total - m_free) / m_total * 100;
}
bool Smb4KShare::equals( const Smb4KShare &share )
{
bool equal = false;
if ( QString::compare( m_name, share.name() ) == 0 &&
QString::compare( m_path, share.path() ) == 0 &&
QString::compare( m_filesystem, share.filesystem() ) == 0 &&
QString::compare( m_cifs_login, share.cifsLogin() ) == 0 &&
(int)m_user.uid() == share.uid() &&
(int)m_group.gid() == share.gid() &&
m_broken == share.isBroken() &&
m_foreign_mount == share.isForeign() &&
m_total == share.totalDiskSpace() &&
m_free == share.freeDiskSpace() )
{
equal = true;
}
return equal;
}

@ -0,0 +1,291 @@
/***************************************************************************
smb4kshare - This is a container that holds information about
a mounted remote share.
-------------------
begin : Do M<EFBFBD> 4 2004
copyright : (C) 2004 by Franck Babin
(C) 2005-2007 by Alexander Reinholdt
email : babinfranck@yahoo.ca
dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARE_H
#define SMB4KSHARE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
#include <qcstring.h>
// KDE includes
#include <kuser.h>
/**
* This class is a container that holds information about a remote share
* that was mounted on the system. It belongs to the core classes of
* Smb4K.
*
* @author Franck Babin,
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KShare
{
public:
/**
* The default constructor.
*
* @param name The name of the share: //HOST/SHARE or //USER\@HOST/SHARE (FreeBSD).
*
* @param path The path where the share is mounted to.
*
* @param filesystem The filesystem that was used. If you use this constructor it should be "smbfs".
*
* @param uid The UID of the user.
*
* @param gid The GID of the user.
*
* @param broken Determines whether the share is broken. "Broken" means that the share is unaccessible.
*/
Smb4KShare( const QString &name, const QString &path, const QString &filesystem, const int uid = 0, const int gid = 0, bool broken = false );
/**
* The constructor for CIFS shares. It does not take the UID and GID, but the
* user name with which the login was done.
*
* @param name The name of the share: //HOST/SHARE or //USER@HOST/SHARE (FreeBSD).
*
* @param path The path where the share is mounted to.
*
* @param filesystem The filesystem that was used. If you use this constructor it should be "cifs".
*
* @param username The the user name that had to be used for authentication. It can be different from the local user name.
*
* @param foreign Determines whether the share was mounted by another user (i.e. is a foreign share).
*
* @param broken Determines whether the share is broken. "Broken" means that the share is unaccessible.
*/
Smb4KShare( const QString &name, const QString &path, const QString &filesystem, const QString &username, bool foreign = false, bool broken = false );
/**
* Empty constructor.
*/
Smb4KShare() {}
/**
* Copy constructor.
*
* @param share The share that is to be copied.
*/
Smb4KShare( const Smb4KShare &share );
/**
* The destructor
*/
~Smb4KShare();
/**
* Returns the name of the share as it has been gathered by the mounter.
*
* @returns The name of the share.
*/
const QString &name() const;
/**
* Returns the mount point aka path of the share as it has been gathered
* by the mounter. This is a C-type string.
*
* @returns The path of the share.
*/
const QCString &path() const;
/**
* This function returns the canonical path of the share. In contrast to
* Smb4KShare::path(), it will return the absolute path without symlinks. However,
* should the share be broken (i.e. Smb4KShare::isBroken() returns TRUE),
* only Smb4KShare::path() is returned.
*
* @returns Returns the canonical path of the share.
*/
const QCString canonicalPath() const;
/**
* Returns the UID of the mounted share.
*/
int uid() const;
/**
* Set the UID of the mounted share.
*
* @param uid The UID of the share
*/
void setUID( int uid );
/**
* Returns the GID of the mounted share.
*/
int gid() const;
/**
* Set the GID of the mounted share.
*
* @param gid The GID of the share
*/
void setGID( int gid );
/**
* Returns the name of the user of the share.
*/
const QString user() const;
/**
* Returns the name of the group of the share.
*/
const QString group() const;
/**
* Returns the file system of the share.
*/
const QString &filesystem() const;
/**
* Returns the CIFS login (user name).
*/
const QString &cifsLogin() const;
/**
* Is TRUE if the share is/seems to be mounted by another
* user.
*
* @returns TRUE if another user mounted the share and FALSE otherwise.
*/
bool isForeign() const;
/**
* This function sets the share to be foreign.
*
* @param foreign TRUE if share is foreign and FALSE otherwise.
*/
void setForeign( bool foreign );
/**
* Returns TRUE if the share is broken and FALSE otherwise.
*/
bool isBroken() const;
/**
* Sets the share to be broken.
*
* @param broken TRUE if the share is broken and FALSE otherwise.
*/
void setBroken( bool broken );
/**
* This function sets the value of the total disk usage. The value has to
* be provided in kilobytes. If the disk usage could not be determined,
* total has to be set to -1.
*
* @param total The total disk usage in kB.
*/
void setTotalDiskSpace( double total );
/**
* This function sets the value of the free space on the share. The value
* has to be provided in kilobytes. If the free space could not be determined,
* free has to be set to -1.
*
* @param free The free disk space in kB.
*/
void setFreeDiskSpace( double free );
/**
* This function returns the total disk space of the share.
*
* @returns The total disk space in kB.
*/
double totalDiskSpace() const;
/**
* This function returns the free disk space available on the share in kB.
*
* @returns the free disk space in kB.
*/
double freeDiskSpace() const;
/**
* This function returns the percentage of used disk space on the
* share.
*
* @returns the percentage of disk space used on the share.
*/
double percentage() const;
/**
* Compare another Smb4KShare object with this one and return TRUE if both
* carry the same data.
*
* @param share The Smb4KShare object that is compared to this one
*
* @returns TRUE if the values match.
*/
bool equals( const Smb4KShare &share );
private:
/**
* The name of the share.
*/
QString m_name;
/**
* The mount point / path of the share
*/
QCString m_path;
/**
* The filesystem string
*/
QString m_filesystem;
/**
* The user ID of the share.
*/
KUser m_user;
/**
* The group ID of the share.
*/
KUserGroup m_group;
/**
* The CIFS login name
*/
QString m_cifs_login;
bool m_foreign_mount;
bool m_broken;
double m_total;
double m_free;
};
#endif

@ -0,0 +1,76 @@
/***************************************************************************
smb4ksynchronizationinfo - This is a container that holds
information about progress of the synchronization
-------------------
begin : So Mai 20 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// application specific includes
#include "smb4ksynchronizationinfo.h"
Smb4KSynchronizationInfo::Smb4KSynchronizationInfo() : m_text( QString::null ),
m_individual_progress( -1 ), m_total_progress( -1 ), m_total_files( -1 ),
m_processed_files( -1 ), m_rate( QString::null )
{
}
Smb4KSynchronizationInfo::~Smb4KSynchronizationInfo()
{
}
void Smb4KSynchronizationInfo::setText( const QString &text )
{
m_text = text;
}
void Smb4KSynchronizationInfo::setIndividualProgress( int percent )
{
m_individual_progress = percent;
}
void Smb4KSynchronizationInfo::setTotalProgress( int percent )
{
m_total_progress = percent;
}
void Smb4KSynchronizationInfo::setTotalFileNumber( int total )
{
m_total_files = total;
}
void Smb4KSynchronizationInfo::setProcessedFileNumber( int processed )
{
m_processed_files = processed;
}
void Smb4KSynchronizationInfo::setTransferRate( const QString &rate )
{
m_rate = rate;
}

@ -0,0 +1,176 @@
/***************************************************************************
smb4ksynchronizationinfo - This is a container that holds
information about progress of the synchronization
-------------------
begin : So Mai 20 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSYNCHRONIZATIONINFO_H
#define SMB4KSYNCHRONIZATIONINFO_H
// Qt includes
#include <qstring.h>
class Smb4KSynchronizationInfo
{
public:
/**
* The constructor. It takes no arguments and you should use the
* setXYZ() functions to set the necessary values.
*/
Smb4KSynchronizationInfo();
/**
* The destructor.
*/
~Smb4KSynchronizationInfo();
/**
* Set the text that's provided in rsync's output. This may either be a
* file name or some information about the progress
*
* @param text The text
*/
void setText( const QString &text );
/**
* Return the name of the file that is currently processed. This may
* be empty if no information about the file name is available.
*
* @returns the name of the file that is currently processed or an empty
* string
*/
const QString &text () const { return m_text; }
/**
* Set the progress of the file that's currently processed.
*
* @param percent The progress in percent
*/
void setIndividualProgress( int percent );
/**
* Return the progress of the current file transfer. If no
* information is available, -1 is returned.
*
* @returns the progress of the current file transfer or -1.
*/
const int individualProgress() const { return m_individual_progress; }
/**
* Set the total progress of synchronization process.
*
* @param percent The progress in percent
*/
void setTotalProgress( int percent );
/**
* Return the total progress of synchronization process. If no
* information is available, -1 is returned.
*
* @returns the total progress of the synchronization or -1.
*/
const int totalProgress() const { return m_total_progress; }
/**
* Set the total number of files that have been considered for the
* synchronization.
*
* @param total The total number of files
*/
void setTotalFileNumber( int total );
/**
* Return the total number of files that were considered for synchronization.
* If no information is available, -1 is returned.
*
* @returns the total number of files or -1.
*/
const int totalFileNumber() const { return m_total_files; }
/**
* Set the number of files that have already been processed during the
* synchronization.
*
* @param processed The number of files that have been processed
*/
void setProcessedFileNumber( int processed );
/**
* Return the number of files that have already been processed during the
* synchronization. If no information is available, -1 is returned.
*
* @returns the number of processed files or -1.
*/
const int processedFileNumber() const { return m_processed_files; }
/**
* Set the transfer rate. This should be a string that already contains
* all information, i.e. the string should look like this: 100 kB/s.
*
* @param rate The rate string (e.g. 100 kB/s)
*/
void setTransferRate( const QString &rate );
/**
* Return the transfer rate. This is a string that already contains all
* information, so that you can just put it into your widget without any
* modification. It may also be empty if no information about the rate is
* available.
*
* @returns The rate or an empty string.
*/
const QString &transferRate() const { return m_rate; }
private:
/**
* The text
*/
QString m_text;
/**
* The individual progress
*/
int m_individual_progress;
/**
* The total progress
*/
int m_total_progress;
/**
* The total file number
*/
int m_total_files;
/**
* The number of processed files
*/
int m_processed_files;
/**
* The rate string
*/
QString m_rate;
};
#endif

@ -0,0 +1,503 @@
/***************************************************************************
smb4ksynchronizer - This is the synchronizer of Smb4K.
-------------------
begin : Mo Jul 4 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qdir.h>
#include <qlabel.h>
#include <qregexp.h>
// KDE includes
#include <kmessagebox.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <klineedit.h>
#include <klocale.h>
#include <kprogress.h>
#include <kurlrequester.h>
#include <kguiitem.h>
#include <kapplication.h>
// application specific includes
#include "smb4ksynchronizer.h"
#include "smb4kdefs.h"
#include "smb4kerror.h"
#include "smb4kglobal.h"
#include "smb4kshare.h"
#include "smb4ksynchronizationinfo.h"
#include "smb4ksettings.h"
using namespace Smb4KGlobal;
bool cancel = false;
Smb4KSynchronizer::Smb4KSynchronizer( QObject *parent, const char *name )
: QObject( parent, name )
{
m_proc = new KProcess( this, "SynchronizerProcess" );
m_proc->setUseShell( true );
m_working = false;
connect( m_proc, SIGNAL( receivedStdout( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStdout( KProcess *, char *, int ) ) );
connect( m_proc, SIGNAL( processExited( KProcess* ) ),
this, SLOT( slotProcessExited( KProcess * ) ) );
connect( m_proc, SIGNAL( receivedStderr( KProcess *, char *, int ) ),
this, SLOT( slotReceivedStderr( KProcess *, char *, int ) ) );
connect( kapp, SIGNAL( shutDown() ),
this, SLOT( slotShutdown() ) );
}
Smb4KSynchronizer::~Smb4KSynchronizer()
{
}
/****************************************************************************
Synchronizes a share with a local copy or vice versa.
****************************************************************************/
void Smb4KSynchronizer::synchronize( const QString &source, const QString &destination )
{
if ( Smb4KSettings::rsync().isEmpty() )
{
Smb4KError::error( ERROR_COMMAND_NOT_FOUND, "rsync" );
return;
}
// FIXME: Do not stop here but buffer the requests and
// process them if the previous process finished.
if ( isRunning() )
{
return;
}
m_working = true;
emit state( SYNCHRONIZER_START );
emit start();
// We will only define the stuff we urgently need
// here. The options that actually influence rsync's
// behavior will be retrieved by readRsyncOptions().
QString command = "rsync --progress ";
command.append( readRsyncOptions() );
command.append( " " );
command.append( KProcess::quote( source ) );
command.append( " " );
command.append( KProcess::quote( destination ) );
*m_proc << command;
// Use KProcess::OwnGroup instead of KProcess::NotifyOnExit here, because
// this garantees that the process is indeed killed when using abort().
// See KProcess docs for further information.
m_proc->start( KProcess::OwnGroup, KProcess::AllOutput );
}
/****************************************************************************
Reads the options that should be used with rsync
****************************************************************************/
const QString Smb4KSynchronizer::readRsyncOptions()
{
QString options;
if ( Smb4KSettings::archiveMode() )
{
options.append( " --archive" );
}
else
{
options.append( Smb4KSettings::recurseIntoDirectories() ?
" --recursive" :
"" );
options.append( Smb4KSettings::preserveSymlinks() ?
" --links" :
"" );
options.append( Smb4KSettings::preservePermissions() ?
" --perms" :
"" );
options.append( Smb4KSettings::preserveTimes() ?
" --times" :
"" );
options.append( Smb4KSettings::preserveGroup() ?
" --group" :
"" );
options.append( Smb4KSettings::preserveOwner() ?
" --owner" :
"" );
options.append( Smb4KSettings::preserveDevicesAndSpecials() ?
" --devices --specials" : // alias: -D
"" );
}
options.append( Smb4KSettings::relativePathNames() ?
" --relative" :
"" );
options.append( Smb4KSettings::omitDirectoryTimes() ?
" --omit-dir-times" :
"" );
options.append( Smb4KSettings::noImpliedDirectories() ?
" --no-implied-dirs" :
"" );
options.append( Smb4KSettings::updateTarget() ?
" --update" :
"" );
options.append( Smb4KSettings::updateInPlace() ?
" --inplace" :
"" );
options.append( Smb4KSettings::transferDirectories() ?
" --dirs" :
"" );
options.append( Smb4KSettings::transformSymlinks() ?
" --copy-links" :
"" );
options.append( Smb4KSettings::transformUnsafeSymlinks() ?
" --copy-unsafe-links" :
"" );
options.append( Smb4KSettings::ignoreUnsafeSymlinks() ?
" --safe-links" :
"" );
options.append( Smb4KSettings::preserveHardLinks() ?
" --hard-links" :
"" );
options.append( Smb4KSettings::keepDirectorySymlinks() ?
" --keep-dirlinks" :
"" );
options.append( Smb4KSettings::deleteExtraneous() ?
" --delete" :
"" );
options.append( Smb4KSettings::removeSourceFiles() ?
" --remove-source-files" :
"" );
options.append( Smb4KSettings::deleteBefore() ?
" --delete-before" :
"" );
options.append( Smb4KSettings::deleteDuring() ?
" --delete-during" :
"" );
options.append( Smb4KSettings::deleteAfter() ?
" --delete-after" :
"" );
options.append( Smb4KSettings::deleteExcluded() ?
" --delete-excluded" :
"" );
options.append( Smb4KSettings::ignoreErrors() ?
" --ignore-errors" :
"" );
options.append( Smb4KSettings::forceDirectoryDeletion() ?
" --force" :
"" );
options.append( Smb4KSettings::copyFilesWhole() ?
" --whole-file" :
"" );
options.append( Smb4KSettings::efficientSparseFileHandling() ?
" --sparse" :
"" );
options.append( Smb4KSettings::oneFileSystem() ?
" --one-file-system" :
"" );
options.append( Smb4KSettings::updateExisting() ?
" --existing" :
"" );
options.append( Smb4KSettings::ignoreExisting() ?
" --ignore-existing" :
"" );
options.append( Smb4KSettings::delayUpdates() ?
" --delay-updates" :
"" );
options.append( Smb4KSettings::compressData() ?
" --compress" :
"" );
if ( Smb4KSettings::makeBackups() )
{
options.append( " --backup" );
options.append( Smb4KSettings::useBackupDirectory() ?
" --backup-dir="+Smb4KSettings::backupDirectory() :
"" );
options.append( Smb4KSettings::useBackupSuffix() ?
" --suffix="+Smb4KSettings::backupSuffix() :
"" );
}
options.append( Smb4KSettings::useMaximumDelete() ?
" --max-delete="+QString( "%1" ).arg( Smb4KSettings::maximumDeleteValue() ) :
"" );
options.append( Smb4KSettings::useChecksum() ?
" --checksum" :
"" );
options.append( Smb4KSettings::useBlockSize() ?
" --block-size="+QString( "%1" ).arg( Smb4KSettings::blockSize() ) :
"" );
options.append( Smb4KSettings::useChecksumSeed() ?
" --checksum-seed="+QString( "%1" ).arg( Smb4KSettings::checksumSeed() ) :
"" );
if ( !Smb4KSettings::customFilteringRules().isEmpty() )
{
options.append( " "+Smb4KSettings::customFilteringRules() );
}
options.append( Smb4KSettings::useMinimalTransferSize() ?
" --min-size="+QString( "%1" ).arg( Smb4KSettings::minimalTransferSize() )+"K" :
"" );
options.append( Smb4KSettings::useMaximalTransferSize() ?
" --max-size="+QString( "%1" ).arg( Smb4KSettings::maximalTransferSize() )+"K" :
"" );
if ( Smb4KSettings::keepPartial() )
{
options.append( " --partial" );
options.append( Smb4KSettings::usePartialDirectory() ?
" --partial-dir="+Smb4KSettings::partialDirectory() :
"" );
}
options.append( Smb4KSettings::useCVSExclude() ?
" --cvs-exclude" :
"" );
options.append( Smb4KSettings::useFFilterRule() ?
" -F" :
"" );
options.append( Smb4KSettings::useFFFilterRule() ?
" -F -F" :
"" );
options.append( Smb4KSettings::useExcludePattern() ?
" --exclude="+Smb4KSettings::excludePattern() :
"" );
options.append( Smb4KSettings::useExcludeFrom() ?
" --exclude-from="+Smb4KSettings::excludeFrom() :
"" );
options.append( Smb4KSettings::useIncludePattern() ?
" --include="+Smb4KSettings::includePattern() :
"" );
options.append( Smb4KSettings::useIncludeFrom() ?
" --include-from="+Smb4KSettings::includeFrom() :
"" );
return options;
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSynchronizer::abort()
{
cancel = true;
if ( m_proc->isRunning() )
{
m_proc->kill();
}
}
void Smb4KSynchronizer::slotProcessExited( KProcess * )
{
m_proc->clearArguments();
m_working = false;
emit finished();
emit state( SYNCHRONIZER_STOP );
}
void Smb4KSynchronizer::slotReceivedStdout( KProcess *, char *buf, int len )
{
m_buffer = QString::fromLocal8Bit( buf, len );
Smb4KSynchronizationInfo sync_info;
QString partial, total, files, rate;
if ( m_buffer[0].isSpace() && m_buffer.contains( "/s ", true ) > 0 )
{
partial = m_buffer.section( "%", 0, 0 ).section( " ", -1, -1 ).stripWhiteSpace();
if ( !partial.isEmpty() )
{
sync_info.setIndividualProgress( partial.toInt() );
}
if ( m_buffer.contains( "to-check=" ) > 0 )
{
// Newer versions of rsync:
QString tmp = m_buffer.section( "to-check=", 1, 1 ).section( ")", 0, 0 ).stripWhiteSpace();
if ( !tmp.isEmpty() )
{
double tmp_total = tmp.section( "/", 1, 1 ).stripWhiteSpace().toInt();
double tmp_done = tmp.section( "/", 0, 0 ).stripWhiteSpace().toInt();
double tmp_percent = ((tmp_total-tmp_done)/tmp_total)*100;
total = QString( "%1" ).arg( tmp_percent ).section( ".", 0, 0 ).stripWhiteSpace();
}
}
else
{
// Older versions of rsync:
total = m_buffer.section( " (", 1, 1 ).section( ",", 1, 1 ).section( "%", 0, 0 ).section( ".", 0, 0 ).stripWhiteSpace();
}
if ( !total.isEmpty() )
{
sync_info.setTotalProgress( total.toInt() );
}
if ( m_buffer.contains( "xfer#" ) > 0 )
{
// Newer versions of rsync:
files = m_buffer.section( "xfer#", 1, 1 ).section( ",", 0, 0 ).stripWhiteSpace();
}
else
{
// Older versions of rsync:
files = m_buffer.section( " (", 1, 1 ).section( ",", 0, 0 ).stripWhiteSpace();
}
if ( !files.isEmpty() )
{
sync_info.setProcessedFileNumber( files.toInt() );
sync_info.setTotalFileNumber( m_total_files.toInt() );
}
rate = m_buffer.section( "/s ", 0, 0 ).section( " ", -1, -1 ).stripWhiteSpace();
if ( !rate.isEmpty() )
{
rate.append( "/s" );
rate.insert( rate.length() - 4, " " );
sync_info.setTransferRate( rate );
}
m_buffer = QString::null;
}
else if ( !m_buffer[0].isSpace() && m_buffer.endsWith( "\n" ) && m_buffer.contains( "/s ", true ) == 0 )
{
sync_info.setText( m_buffer.stripWhiteSpace() );
if ( m_buffer.contains( "files to consider" ) != 0 )
{
m_total_files = m_buffer.section( " files to consider", 0, 0 ).section( " ", -1, -1 ).stripWhiteSpace();
sync_info.setTotalFileNumber( m_total_files.toInt() );
}
m_buffer = QString::null;
}
emit progress( sync_info );
}
void Smb4KSynchronizer::slotReceivedStderr( KProcess *, char *buf, int len )
{
QString error_message = QString::fromLocal8Bit( buf, len );
// At least under Debian unstable (20051216), rsync emits an error
// when you kill the process (using SIGTERM). Pressing the cancel
// button will exactly do this. Thus, we need to exclude this occasion
// from here.
if ( !cancel && error_message.contains( "rsync error:", true ) != 0 )
{
// Cancel the whole synchronization in case an error occurred.
// If we don't do it, the user might be flooded with error messages
// especially if you try to synchronize a local copy with a remote
// share that is mounted read-only.
abort();
Smb4KError::error( ERROR_SYNCHRONIZING, QString::null, error_message );
}
else
{
cancel = false;
}
}
void Smb4KSynchronizer::slotShutdown()
{
abort();
}
#include "smb4ksynchronizer.moc"

@ -0,0 +1,194 @@
/***************************************************************************
smb4ksynchronizer - This is the synchronizer of Smb4K.
-------------------
begin : Mo Jul 4 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSYNCHRONIZER_H
#define SMB4KSYNCHRONIZER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kprocess.h>
#include <kdialogbase.h>
// Qt includes
#include <qobject.h>
#include <qstring.h>
// forward declarations
class Smb4KShare;
class Smb4KSynchronizationInfo;
/**
* This is a core class of Smb4K. It manages the synchronization of remote
* shares with a local copy (and vice versa).
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSynchronizer : public QObject
{
Q_OBJECT
public:
/**
* The constructor of the synchronizer.
*
* @param parent The parent of this object
*
* @param name The name of this object
*/
Smb4KSynchronizer( QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KSynchronizer();
/**
* This function synchronizes a destination with the source.
*
* @param source The source location
*
* @param destination The destination
*/
void synchronize( const QString &source, const QString &destination );
/**
* This function reports if the synchronizer is running or not.
*
* @returns TRUE if the synchronizer is running an FALSE otherwise.
*/
bool isRunning() { return m_working; }
public slots:
/**
* This function aborts the synchronization, i.e. the sync process is killed.
*/
void abort();
signals:
/**
* This signal emits the run state.
*
* @param state The so-called run state. There are several defined
* in the smb4kdefs.h header file.
*/
void state( int state );
/**
* This signal is emitted just before the synchronization process is
* started.
*/
void start();
/**
* This signal is emitted when the synchronization process finished.
*/
void finished();
/**
* Emit information about the progress of current synchronization process.
* The information that's available may only be partial, i.e. that maybe
* the file name or the rate or somthing else is missing. That's because
* of the way the output of rsync is processed.
*
* @param info Information about progress of the synchronization
* process
*/
void progress( const Smb4KSynchronizationInfo &info );
protected slots:
/**
* Reimplemented from KProcess.
*
* @param proc The process that exited
*/
void slotProcessExited( KProcess *proc );
/**
* Reimplemented from KProcess.
*
* @param proc The process from which output was received on stdout
*
* @param buf The buffer that contains the output
*
* @param len The length of the buffer
*/
void slotReceivedStdout( KProcess *proc, char *buf, int len );
/**
* Reimplemented from KProcess.
*
* @param proc The process from which output was received on stderr
*
* @param buf The buffer that contains the output
*
* @param len The length of the buffer
*/
void slotReceivedStderr( KProcess *proc, char *buf, int len );
/**
* This slot is connected to KApplication::shutDown() signal.
* It aborts the running KProcess if necessary.
*/
void slotShutdown();
private:
/**
* The process object for this class.
*/
KProcess *m_proc;
/**
* This booian is TRUE if the synchronizer is working and FALSE otherwise.
*/
bool m_working;
/**
* This function reads the options, that the user chose to use with rsync.
*
* @returns an option string
*/
const QString readRsyncOptions();
/**
* The buffer for the output.
*
* NOTE: The buffer is not to contain error messages, that are received
* via slotReceivedStderr()!
*/
QString m_buffer;
/**
* Total number of files to transfer
*/
QString m_total_files;
};
#endif

@ -0,0 +1,11 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
lib_LTLIBRARIES = libsmb4kdialogs.la
libsmb4kdialogs_la_LDFLAGS = -avoid-version -no-undefined $(all_libraries)
libsmb4kdialogs_la_SOURCES = smb4kbookmarkeditor.cpp \
smb4kcustomoptionsdialog.cpp smb4kmountdialog.cpp smb4kpreviewdialog.cpp smb4kprintdialog.cpp \
smb4ksynchronizationdialog.cpp
libsmb4kdialogs_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(LIB_KDECORE) $(LIB_KDEUI) $(LIB_QT)
noinst_HEADERS = smb4kbookmarkeditor.h smb4kmountdialog.h smb4kpreviewdialog.h \
smb4kprintdialog.h smb4ksynchronizationdialog.h

@ -0,0 +1,258 @@
/***************************************************************************
smb4kbookmarkeditor - This is the bookmark editor of Smb4K.
-------------------
begin : Di Okt 5 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qvaluelist.h>
// KDE includes
#include <klocale.h>
#include <kaction.h>
#include <kactionclasses.h>
#include <kaccel.h>
#include <kiconloader.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <kapplication.h>
#include <kpopupmenu.h>
// application specific includes
#include "smb4kbookmarkeditor.h"
#include "../core/smb4kbookmark.h"
#include "../core/smb4kcore.h"
#include "../core/smb4kglobal.h"
#include "../core/smb4ksettings.h"
using namespace Smb4KGlobal;
Smb4KBookmarkEditor::Smb4KBookmarkEditor( QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Bookmark Editor" ), Ok|Cancel, Ok, parent, name, true, true )
{
setWFlags( Qt::WDestructiveClose );
QFrame *frame = plainPage();
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 5 );
m_view = new KListView( frame );
m_view->addColumn( i18n( "Bookmark" ), Bookmark );
m_view->addColumn( i18n( "Workgroup" ), Workgroup );
m_view->addColumn( i18n( "IP Address" ), IPAddress );
m_view->addColumn( i18n( "Label" ), Label );
// m_view->setAllColumnsShowFocus( true );
m_view->setItemsRenameable( true );
m_view->setRenameable( Bookmark, false );
m_view->setRenameable( Workgroup, false );
m_view->setRenameable( IPAddress, true );
m_view->setRenameable( Label, true );
m_collection = new KActionCollection( this, "BookmarkEditor_ActionCollection", KGlobal::instance() );
(void) new KAction( i18n( "&Remove" ), "remove", Key_Delete, this, SLOT( slotRemoveClicked() ), m_collection, "remove_bookmark" );
(void) new KAction( i18n( "Remove &All" ), "editdelete", CTRL+Key_X, this, SLOT( slotDeleteAllClicked() ), m_collection, "remove_all_bookmarks" );
slotLoadBookmarks();
layout->addWidget( m_view, 0, 0, 0 );
setInitialSize( configDialogSize( *(Smb4KSettings::self()->config()), "BookmarkEditor" ) );
setMinimumSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
connect( m_view, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
this, SLOT( slotRightButtonPressed( QListViewItem *, const QPoint &, int ) ) );
connect( m_view, SIGNAL( itemRenamed( QListViewItem * ) ),
this, SLOT( slotItemRenamed( QListViewItem * ) ) );
connect( this, SIGNAL( okClicked() ),
this, SLOT( slotOkClicked() ) );
connect( this, SIGNAL( cancelClicked() ),
this, SLOT( slotCancelClicked() ) );
connect( Smb4KCore::bookmarkHandler(), SIGNAL( bookmarksUpdated() ),
this, SLOT( slotLoadBookmarks() ) );
}
Smb4KBookmarkEditor::~Smb4KBookmarkEditor()
{
uint index = 0;
while ( index < m_collection->count() )
{
delete m_collection->action( index++ );
}
m_collection->clear();
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KBookmarkEditor::slotRightButtonPressed( QListViewItem *item, const QPoint &pos, int )
{
if ( !item )
{
m_collection->action( "remove_bookmark" )->setEnabled( false );
}
else
{
m_collection->action( "remove_bookmark" )->setEnabled( true );
}
if ( m_view->childCount() == 0 )
{
m_collection->action( "remove_all_bookmarks" )->setEnabled( false );
}
else
{
m_collection->action( "remove_all_bookmarks" )->setEnabled( true );
}
KActionMenu *menu = static_cast<KActionMenu *>( child( "BookmarkEditorPopupMenu", "KActionMenu", true ) );
if ( !menu )
{
menu = new KActionMenu( this, "BookmarkEditorPopupMenu" );
menu->insert( m_collection->action( "remove_bookmark" ) );
menu->insert( m_collection->action( "remove_all_bookmarks" ) );
}
menu->popup( pos );
}
void Smb4KBookmarkEditor::slotRemoveClicked()
{
if ( m_view->currentItem() )
{
delete m_view->currentItem();
}
// Adjust the columns:
for ( int col = 0; col < m_view->columns(); col++ )
{
m_view->adjustColumn( col );
}
}
void Smb4KBookmarkEditor::slotDeleteAllClicked()
{
m_view->clear();
// Adjust the columns:
for ( int col = 0; col < m_view->columns(); col++ )
{
m_view->adjustColumn( col );
}
}
void Smb4KBookmarkEditor::slotOkClicked()
{
KActionPtrList list = m_collection->actions( "BookmarkEditor" );
for ( KActionPtrList::Iterator it = list.begin(); it != list.end(); ++it )
{
delete *it;
}
QValueList<Smb4KBookmark *> bookmarks;
if ( m_view->childCount() != 0 )
{
QListViewItemIterator it( m_view );
while( it.current() )
{
bookmarks.append( new Smb4KBookmark(
it.current()->text( Bookmark ).section( "/", 2, 2 ).stripWhiteSpace(),
it.current()->text( Bookmark ).section( "/", 3, 3 ).stripWhiteSpace(),
it.current()->text( Workgroup ).stripWhiteSpace(),
it.current()->text( IPAddress ).stripWhiteSpace(),
"Disk",
it.current()->text( Label ).stripWhiteSpace() ) );
++it;
}
}
Smb4KCore::bookmarkHandler()->writeBookmarkList( bookmarks );
saveDialogSize( *(Smb4KSettings::self()->config()), "BookmarkEditor" );
}
void Smb4KBookmarkEditor::slotCancelClicked()
{
KActionPtrList list = m_collection->actions( "BookmarkEditor" );
for ( KActionPtrList::Iterator it = list.begin(); it != list.end(); ++it )
{
m_collection->kaccel()->remove( (*it)->name() );
m_collection->remove( *it );
}
}
void Smb4KBookmarkEditor::slotLoadBookmarks()
{
m_view->clear();
QValueList<Smb4KBookmark *> bookmarks = Smb4KCore::bookmarkHandler()->getBookmarks();
for ( QValueList<Smb4KBookmark *>::ConstIterator it = bookmarks.begin(); it != bookmarks.end(); ++it )
{
KListViewItem *item = new KListViewItem( m_view );
item->setText( Bookmark, (*it)->bookmark() );
item->setText( Workgroup, (*it)->workgroup() );
item->setText( IPAddress, (*it)->ip() );
item->setText( Label, (*it)->label() );
item->setPixmap( Bookmark, SmallIcon( "folder" ) );
}
// Adjust the columns:
for ( int col = 0; col < m_view->columns(); col++ )
{
m_view->adjustColumn( col );
}
}
void Smb4KBookmarkEditor::slotItemRenamed( QListViewItem * )
{
// Adjust the columns:
for ( int col = 0; col < m_view->columns(); col++ )
{
m_view->adjustColumn( col );
}
}
#include "smb4kbookmarkeditor.moc"

@ -0,0 +1,137 @@
/***************************************************************************
smb4kbookmarkeditor - description
-------------------
begin : Di Okt 5 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KBOOKMARKEDITOR_H
#define SMB4KBOOKMARKEDITOR_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kdialogbase.h>
#include <klistview.h>
#include <kactioncollection.h>
/**
* This is the bookmark editor of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KBookmarkEditor : public KDialogBase
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent of this dialog.
*
* @param name The name of this dialog.
*/
Smb4KBookmarkEditor( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KBookmarkEditor();
/**
* This function returns a pointer to the action collection of this class.
* You should use it to include the action into the action collection of the
* main action collection (e.g. KMainWindow::actionCollection()).
*
* The entries in this action collection are members of the group "BookmarkEditor".
*
* @returns a pointer to the action collection of this class
*/
KActionCollection *action_collection() { return m_collection; }
protected slots:
/**
* This slot is activated whenever the right mouse button
* has been pressed.
*
* @param item The item over which the mouse pointer is (maybe NULL).
*
* @param pos The position where the mouse is.
*
* @param col The column of the list view item.
*/
void slotRightButtonPressed ( QListViewItem *item, const QPoint &pos, int col );
/**
* This slot is activated whenever the remove button of the
* menu is clicked.
*/
void slotRemoveClicked();
/**
* This slot is activated whenever the 'Remove All' button of
* the menu has been clicked.
*/
void slotDeleteAllClicked();
/**
* This slot is activated if the OK button has been clicked.
*/
void slotOkClicked();
/**
* This slot is activated if the Cancel button has been clicked.
*/
void slotCancelClicked();
/**
* This slot is invoked, if the bookmark handler updated the bookmarks.
*/
void slotLoadBookmarks();
/**
* This slot is invoked when an item was renamed. It will adjust the columns.
*
* @param item The item that was renamed.
*/
void slotItemRenamed( QListViewItem *item );
private:
/**
* Enumeration for the columns in the list view.
*/
enum Columns { Bookmark = 0, Workgroup = 1, IPAddress = 2, Label = 3 };
/**
* The listview.
*/
KListView *m_view;
/**
* The action collection of this class.
*/
KActionCollection *m_collection;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,232 @@
/***************************************************************************
smb4kcustomoptionsdialog - With this dialog the user can define
custom Samba options for hosts or shares.
-------------------
begin : So Jun 25 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 *
***************************************************************************/
#ifndef SMB4KCUSTOMOPTIONSDIALOG_H
#define SMB4KCUSTOMOPTIONSDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qcheckbox.h>
// KDE includes
#include <kdialogbase.h>
#include <knuminput.h>
#include <kcombobox.h>
#include <klineedit.h>
// forward declarations
class Smb4KHostItem;
class Smb4KShareItem;
class Smb4KCustomOptionsDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* The constructor
*
* @param host The host (server) for which the custom options should be defined.
*
* @param parent The parent of this dialog
*
* @param name The name of this dialog
*/
Smb4KCustomOptionsDialog( Smb4KHostItem *host, QWidget *parent = 0, const char *name = 0 );
/**
* Another constructor, similar to the one above.
*
* @param share The share for which the custom options should be defined.
*
* @param parent The parent of this dialog
*
* @param name The name of this dialog
*/
Smb4KCustomOptionsDialog( Smb4KShareItem *share, QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KCustomOptionsDialog();
/**
* This function returns TRUE if the dialog has been initialized correctly
* and may be shown now. It will always return TRUE if you want to set options
* for a server or for a share, that is not a 'homes' share. Only in the case
* of a homes share it may return FALSE, if you didn't choose a user name.
*
* @returns TRUE if the dialog has been set up correctly.
*/
bool isInitialized() { return m_initialized; }
protected slots:
/**
* Is invoked when the port value changed
*
* @param int The port number
*/
void slotPortChanged( int value );
/**
* Is invoked when the file system value changed
*
* @param fs The file system
*/
void slotFilesystemChanged( const QString &fs );
/**
* Is invoked when the protocol value changed
*
* @param t The protocol
*/
void slotProtocolChanged( const QString &p );
/**
* Is invoked when the user clicked the 'Use Kerberos'
* check box.
*
* @param on TRUE if the check box was
* checked and FALSE otherwise
*/
void slotKerberosToggled( bool on );
/**
* Commit the custom options provided for the selected
* network item.
*/
void slotOKButtonClicked();
/**
* Is invoked if the "Default" button has been pressed.
*/
void slotDefaultButtonClicked();
/**
* This slot is invoked when the "Write Access" value changed.
*
* @param rw Either 'read-write' or 'read-only' (localized).
*/
void slotWriteAccessChanged( const QString &rw );
/**
* This slot is invoked when the UID value changed.
*
* @param uid The UID value
*/
void slotUIDChanged( const QString &uid );
/**
* This slot is invoked when the GID value changed.
*
* @param gid The UID value
*/
void slotGIDChanged( const QString &gid );
private:
/**
* Enumeration
*/
enum ItemType{ Host, Share };
/**
* The item type
*/
int m_type;
/**
* Sets up the dialog
*/
void setupDialog();
/**
* The host item (is NULL if you process a share).
*/
Smb4KHostItem *m_host_item;
/**
* The share item (is NULL if you process a host).
*/
Smb4KShareItem *m_share_item;
/**
* Port input
*/
KIntNumInput *m_port_input;
#ifndef __FreeBSD__
/**
* The file system
*/
KComboBox *m_fs_input;
/**
* This combo box determines if the user wants to mount a share
* readwrite or readonly.
*/
KComboBox *m_rw_input;
#endif
/**
* The protocol
*/
KComboBox *m_proto_input;
/**
* Boolean that is TRUE if the dialog has been initialized
* correctly and my be shown now.
*/
bool m_initialized;
/**
* This will only be set if we are dealing with a 'homes' share.
*/
QString m_homes_user;
/**
* This check box will determine if the user wants to try to
* authenticate with Kerberos or not. This is needed for Active
* Directory stuff.
*/
QCheckBox *m_kerberos;
/**
* This combo box holds the values of the UID that the user can
* chose from.
*/
KLineEdit *m_uid_input;
/**
* This combo box holds the values of the GID that the user can
* chose from.
*/
KLineEdit *m_gid_input;
};
#endif

@ -0,0 +1,172 @@
/***************************************************************************
smb4kmountdialog - This class provides a dialog for mounting shares
manually.
-------------------
begin : Mo Nov 29 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h>
// KDE includes
#include <klocale.h>
#include <kmessagebox.h>
#include <kdebug.h>
// application specific includes
#include "smb4kmountdialog.h"
#include "../core/smb4kmounter.h"
#include "../core/smb4kbookmarkhandler.h"
#include "../core/smb4kbookmark.h"
#include "../core/smb4kcore.h"
#include "../smb4k.h"
Smb4KMountDialog::Smb4KMountDialog( QWidget *parent, const char *name ) :
KDialogBase( Plain, i18n( "Mount Share" ), Ok|Cancel, Ok, parent, name, true, true )
{
setWFlags( Qt::WDestructiveClose );
setupView();
setFixedSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
}
Smb4KMountDialog::~Smb4KMountDialog()
{
}
void Smb4KMountDialog::setupView()
{
QFrame *frame = plainPage();
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 5 );
layout->setMargin( 0 );
QLabel *shareLabel = new QLabel( i18n( "Share:" ), frame );
m_share_input = new KLineEdit( frame, "ShareInputLine" );
m_share_input->setMinimumWidth( 200 );
m_share_input->setFocus();
QLabel *addressLabel = new QLabel( i18n( "IP Address:" ), frame );
m_ip_input = new KLineEdit( frame, "IPInputLine" );
m_ip_input->setMinimumWidth( 200 );
QLabel *workgroupLabel = new QLabel( i18n( "Workgroup:" ), frame );
m_workgroup_input = new KLineEdit( frame, "WorkgroupInputLine" );
m_workgroup_input->setMinimumWidth( 200 );
m_bookmark = new QCheckBox( i18n( "Add this share to the bookmarks" ), frame, "BookmarkButton" );
layout->addWidget( shareLabel, 0, 0, 0 );
layout->addWidget( m_share_input, 0, 1, 0 );
layout->addWidget( addressLabel, 1, 0, 0 );
layout->addWidget( m_ip_input, 1, 1, 0 );
layout->addWidget( workgroupLabel, 2, 0, 0 );
layout->addWidget( m_workgroup_input, 2, 1, 0 );
layout->addMultiCellWidget( m_bookmark, 3, 3, 0, 1, 0 );
connect( m_share_input, SIGNAL( textChanged ( const QString & ) ) ,
this, SLOT( slotChangeInputValue( const QString & ) ) );
slotChangeInputValue( m_share_input->text() );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KMountDialog::slotChangeInputValue( const QString& _test)
{
enableButtonOK( !_test.isEmpty() );
}
void Smb4KMountDialog::slotOk()
{
// FIXME: Leave the decision if the share is not formatted
// correctly up to the mounter. Just pass the string to
// Smb4KCore::mounter()->mountShare().
if ( !m_share_input->text().stripWhiteSpace().isEmpty() )
{
#ifndef __FreeBSD__
if ( m_share_input->text().contains( "/" ) == 3 )
#else
if ( m_share_input->text().contains( "/" ) == 3
&& m_share_input->text().contains( '@' ) == 0 )
#endif
{
QString host = m_share_input->text().stripWhiteSpace().section( "/", 2, 2 );
QString share = m_share_input->text().stripWhiteSpace().section( "/", 3, 3 );
QString ip = m_ip_input->text().stripWhiteSpace();
QString workgroup = m_workgroup_input->text().stripWhiteSpace();
Smb4KCore::mounter()->mountShare( workgroup, host, ip, share );
if ( m_bookmark->isChecked() )
{
Smb4KCore::bookmarkHandler()->addBookmark( new Smb4KBookmark( host, share, workgroup, ip, QString::null ) );
}
connect( Smb4KCore::mounter(), SIGNAL( state( int ) ), this, SLOT( slotMounterStateChanged( int ) ) );
}
else
{
KMessageBox::error( this, i18n( "The format of the share you entered is not correct. It must have the form //HOST/SHARE." ) );
}
}
}
void Smb4KMountDialog::slotCancel()
{
Smb4KCore::mounter()->abort();
KDialogBase::slotCancel();
}
void Smb4KMountDialog::slotMounterStateChanged( int state )
{
switch ( state )
{
case MOUNTER_STOP:
{
accept();
break;
}
default:
{
break;
}
}
}
#include "smb4kmountdialog.moc"

@ -0,0 +1,111 @@
/***************************************************************************
smb4kmountdialog - This class provides a dialog for mounting shares
manually.
-------------------
begin : Mo Nov 29 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KMOUNTDIALOG_H
#define SMB4KMOUNTDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qcheckbox.h>
// KDE includes
#include <kdialogbase.h>
#include <klineedit.h>
/**
* This class provides a dialog with which you can mount shares "manually".
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KMountDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* The constructor.
*/
Smb4KMountDialog( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KMountDialog();
protected slots:
/**
* Reimplemented from KDialogBase.
*/
void slotOk();
/**
* Reimplemented from KDoalogBase.
*/
void slotCancel();
/**
* This slot is being enabled if there is input text.
*
* @param text The input text.
*/
void slotChangeInputValue( const QString &text );
/**
* This slot is connected to the Smb4KCore::mounter()::state() signal.
* It is used to close the dialog.
*
* @param state The state of the mounter.
*/
void slotMounterStateChanged( int state );
private:
/**
* This function sets up the view.
*/
void setupView();
/**
* The line edit where the user has to enter the share.
*/
KLineEdit *m_share_input;
/**
* The line edit where the user can enter the IP address.
*/
KLineEdit *m_ip_input;
/**
* The line edit where the user can enter the workgroup.
*/
KLineEdit *m_workgroup_input;
/**
* This checkbox determines whether the share should be added to the
* bookmarks.
*/
QCheckBox *m_bookmark;
};
#endif

@ -0,0 +1,399 @@
/***************************************************************************
smb4kpreviewdialog.cpp - The preview dialog of Smb4K
-------------------
begin : Fre Jul 4 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qtooltip.h>
#include <qiconset.h>
// KDE includes
#include <klocale.h>
#include <kapplication.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <ktoolbarbutton.h>
// application specific includes
#include "smb4kpreviewdialog.h"
#include "../core/smb4kcore.h"
#include "../core/smb4knetworkitems.h"
#include "../core/smb4ksettings.h"
Smb4KPreviewDialog::Smb4KPreviewDialog( Smb4KShareItem *item, QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Preview" ), Close, Close, parent, name, false, true )
{
setWFlags( Qt::WDestructiveClose );
m_item = new Smb4KPreviewItem( item );
if ( m_item )
{
if ( Smb4KHostItem *host = Smb4KCore::scanner()->getHost( item->host(), item->workgroup() ) )
{
m_item->setIP( host->ip() );
}
m_button_id = None;
m_current_item = m_history.end();
setupView();
setInitialSize( configDialogSize( *(Smb4KSettings::self()->config()), "PreviewDialog" ) );
connect( m_view, SIGNAL( executed( QIconViewItem * ) ),
this, SLOT( slotItemExecuted( QIconViewItem * ) ) );
connect( m_toolbar, SIGNAL( clicked( int ) ),
this, SLOT( slotButtonClicked( int ) ) );
connect( m_combo, SIGNAL( activated( const QString & ) ),
this, SLOT( slotItemActivated( const QString & ) ) );
connect( Smb4KCore::previewer(), SIGNAL( result( Smb4KPreviewItem * ) ),
this, SLOT( slotReceivedData( Smb4KPreviewItem * ) ) );
m_initialized = Smb4KCore::previewer()->preview( m_item );
}
setMinimumSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
}
Smb4KPreviewDialog::~Smb4KPreviewDialog()
{
delete m_item;
}
void Smb4KPreviewDialog::setupView()
{
QFrame *frame = plainPage();
QGridLayout *layout = new QGridLayout( frame );
m_view = new KIconView( frame, 0, 0 );
m_view->setItemTextPos( KIconView::Right );
m_view->setResizeMode( KIconView::Adjust );
m_view->setArrangement( KIconView::TopToBottom );
m_view->setSpacing( 1 );
m_view->setGridX( 200 );
m_view->setWordWrapIconText( false );
m_view->setShowToolTips( true );
m_view->setAutoArrange( true );
m_view->setSorting( true, true );
m_toolbar = new KToolBar( frame, 0, true, false );
m_toolbar->insertButton( "reload", Reload, true, i18n( "Reload" ), 0 );
m_toolbar->insertButton( "back", Back, false, i18n( "Back" ), 1 );
m_toolbar->insertButton( "forward", Forward, false, i18n( "Forward" ), 2 );
m_toolbar->insertButton( "up", Up, false, i18n( "Up" ), 3 );
m_combo = new KComboBox( false, m_toolbar, 0 );
m_combo->listBox()->setHScrollBarMode( QScrollView::Auto );
m_combo->listBox()->setVScrollBarMode( QScrollView::Auto );
m_combo->listBox()->setMinimumHeight( 100 );
m_toolbar->insertWidget( Combo, 10, m_combo, 4 );
m_toolbar->setItemAutoSized( Combo, true );
layout->addWidget( m_view, 0, 0, 0 );
layout->addWidget( m_toolbar, 1, 0, 0 );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KPreviewDialog::slotReceivedData( Smb4KPreviewItem *item )
{
// If the item is NULL or not equal to m_item,
// stop right here:
if ( !item || item != m_item )
{
return;
}
// Clear the icon view:
m_view->clear();
// The item should be equal to m_item, so we can use either of those
// pointers.
// Process the data:
if ( !item->contents().isEmpty() )
{
// Generate the history.
switch ( m_button_id )
{
case Reload: /* Really? */
case Back:
case Forward:
{
// Do not insert anything into the history if
// one of these three buttons was clicked.
break;
}
default:
{
m_history.append( item->location() );
m_current_item = --m_history.end();
break;
}
}
// Clear the combo box, put the new history there and set the
// current item:
m_combo->clear();
for ( QStringList::Iterator it = m_history.begin(); it != m_history.end(); it++ )
{
if ( !m_combo->listBox()->findItem( *it, Qt::CaseSensitive|Qt::ExactMatch ) )
{
m_combo->insertItem( *it, -1 );
}
}
m_combo->setCurrentText( *m_current_item );
// Now put the contents in the icon view:
for ( QValueList<ContentsItem>::ConstIterator it = item->contents().begin();
it != item->contents().end(); ++it )
{
switch ( (*it).first )
{
case Smb4KPreviewItem::File:
{
KIconViewItem *view_item = new KIconViewItem( m_view, (*it).second, SmallIcon( "file" ) );
view_item->setKey( QString( "[file]_%1" ).arg( (*it).second ) );
break;
}
case Smb4KPreviewItem::Directory:
{
// We do not want to show the '.' and '..' directories.
if ( QString::compare( (*it).second, "." ) != 0 && QString::compare( (*it).second, ".." ) != 0 )
{
KIconViewItem *view_item = new KIconViewItem( m_view, (*it).second, SmallIcon( "folder" ) );
view_item->setKey( QString( "[directory]_%1" ).arg( (*it).second ) );
}
break;
}
case Smb4KPreviewItem::HiddenFile:
{
if ( Smb4KSettings::previewHiddenItems() )
{
KIconViewItem *view_item = new KIconViewItem( m_view, (*it).second, SmallIcon( "file" ) );
view_item->setKey( QString( "[file]_%1" ).arg( (*it).second ) );
}
break;
}
case Smb4KPreviewItem::HiddenDirectory:
{
if ( Smb4KSettings::previewHiddenItems() &&
QString::compare( (*it).second, "." ) != 0 && QString::compare( (*it).second, ".." ) != 0 )
{
KIconViewItem *view_item = new KIconViewItem( m_view, (*it).second, SmallIcon( "folder" ) );
view_item->setKey( QString( "[directory]_%1" ).arg( (*it).second ) );
}
break;
}
default:
{
break;
}
}
}
// Now activate or deactivate the buttons:
// Activate the 'Up' button if the current address is
// not equal to the base address.
m_toolbar->setItemEnabled( Up, QString::compare( "//"+item->host()+"/"+item->share()+"/", item->location() ) != 0 );
// Activate/Deactivate 'Back' and 'Forward' buttons.
m_toolbar->setItemEnabled( Back, m_current_item != m_history.at( 0 ) );
m_toolbar->setItemEnabled( Forward, m_current_item != m_history.at( m_history.count() - 1 ) );
}
else
{
return;
}
}
void Smb4KPreviewDialog::slotItemExecuted( QIconViewItem *item )
{
if ( !item->key().startsWith( "[file]_" ) )
{
m_button_id = None;
m_item->setPath( m_item->path()+item->text()+"/" );
Smb4KCore::previewer()->preview( m_item );
}
}
void Smb4KPreviewDialog::slotButtonClicked( int id )
{
m_button_id = id;
m_item->clearContents();
switch ( id )
{
case Reload:
{
Smb4KCore::previewer()->preview( m_item );
break;
}
case Up:
{
// Do nothing if the path is empty because
// we are already in the root directory.
if ( m_item->path().isEmpty() )
{
return;
}
if ( m_item->path().contains( "/" ) > 1 )
{
m_item->setPath( m_item->path().section( "/", 0, -3 ).append( "/" ) );
}
else if ( m_item->path().contains( "/", true ) == 1 )
{
m_item->setPath( QString::null );
}
Smb4KCore::previewer()->preview( m_item );
break;
}
case Back:
{
// Move one item back in the list:
if ( m_current_item != m_history.at( 0 ) )
{
m_current_item--;
}
else
{
return;
}
// Get the path:
if ( (*m_current_item).contains( "/", true ) == 3 )
{
m_item->setPath( QString::null );
}
else
{
m_item->setPath( (*m_current_item).section( "/", 4, -1 ) );
if ( !m_item->path().isEmpty() )
{
m_item->setPath( m_item->path()+"/" );
}
else
{
// Do nothing.
}
}
Smb4KCore::previewer()->preview( m_item );
break;
}
case Forward:
{
// Move one item forward in the list:
if ( m_current_item != m_history.at( m_history.count() - 1 ) )
{
m_current_item++;
}
else
{
return;
}
// Get the path:
if ( (*m_current_item).contains( "/", true ) == 3 )
{
m_item->setPath( QString::null );
}
else
{
m_item->setPath( (*m_current_item).section( "/", 4, -1 ) );
if ( !m_item->path().isEmpty() )
{
m_item->setPath( m_item->path()+"/" );
}
else
{
// Do nothing.
}
}
Smb4KCore::previewer()->preview( m_item );
break;
}
default:
{
break;
}
}
}
void Smb4KPreviewDialog::slotItemActivated( const QString &item )
{
m_button_id = Combo;
// First we have to strip the address:
m_item->setPath( item.section( "//"+m_item->host()+"/"+m_item->share()+"/", 1, 1 ).stripWhiteSpace() );
Smb4KCore::previewer()->preview( m_item );
}
void Smb4KPreviewDialog::slotClose()
{
saveDialogSize( *(Smb4KSettings::self()->config()), "PreviewDialog" );
KDialogBase::slotClose();
}
#include "smb4kpreviewdialog.moc"

@ -0,0 +1,167 @@
/***************************************************************************
smb4kpreviewdialog.h - The preview dialog of Smb4K
-------------------
begin : Fre Jul 4 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KPREVIEWDIALOG_H
#define SMB4KPREVIEWDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qvaluelist.h>
// KDE includes
#include <kdialogbase.h>
#include <kiconview.h>
#include <ktoolbar.h>
#include <kcombobox.h>
// application specific includes
#include "../core/smb4kpreviewitem.h"
// forward declarations
class Smb4KShareItem;
/**
* This is the preview dialog of Smb4K. You can preview remote
* shares with it.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPreviewDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* This is the constructor of the preview dialog.
*
* @param item The Smb4KShareItem object.
*
* @param parent The parent of this widget
*
* @param name The name of this widget
*/
Smb4KPreviewDialog( Smb4KShareItem *item, QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KPreviewDialog();
/**
* This function returns TRUE if the preview dialog has been
* initialized correctly and FALSE otherwise.
*
* @returns TRUE if the dialog was initialized correctly.
*/
bool isInitialized() { return m_initialized; }
protected slots:
/**
* This slot receives the results of the attempt to generate
* a preview.
*
* @param item The Smb4KPreviewItem for which a preview
* was generated.
*/
void slotReceivedData( Smb4KPreviewItem *item );
/**
* Is called, if one icon view item is clicked.
*/
void slotItemExecuted( QIconViewItem *item );
/**
* Is called, if a tool bar button is clicked.
*/
void slotButtonClicked( int id );
/**
* Is called, if an item in the combo box is activated.
*/
void slotItemActivated( const QString &item );
/**
* Reimplemented from KDialogBase. Saves the dialog size and
* then executes KDialogBase::slotClose().
*/
void slotClose();
private:
/**
* Enumeration for the buttons.
*/
enum ButtonID{ Reload, Up, Back, Forward, Combo, None };
/**
* The current button id
*/
int m_button_id;
/**
* Sets up the file view.
*/
void setupView();
/**
* The icon view.
*/
KIconView *m_view;
/**
* The toolbar.
*/
KToolBar *m_toolbar;
/**
* The combo box.
*/
KComboBox *m_combo;
/**
* The private Smb4KHostItem object
*/
Smb4KPreviewItem *m_item;
/**
* This list holds the history of the session.
*/
QStringList m_history;
/**
* This iterator points to the current item in the history.
*/
QStringList::Iterator m_current_item;
/**
* TRUE if the dialog was successfully initilized and
* FALSE otherwise.
*/
bool m_initialized;
};
#endif

@ -0,0 +1,196 @@
/***************************************************************************
smb4kprintdialog - The print dialog for Smb4K
-------------------
begin : So Apr 11 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlabel.h>
#include <qlayout.h>
#include <qframe.h>
// KDE includes
#include <klocale.h>
#include <kmessagebox.h>
#include <kurlrequester.h>
#include <knuminput.h>
#include <kdebug.h>
// application specific includes
#include "smb4kprintdialog.h"
#include "../core/smb4kprintinfo.h"
#include "../core/smb4kcore.h"
#include "../core/smb4knetworkitems.h"
Smb4KPrintDialog::Smb4KPrintDialog( Smb4KShareItem *item, QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Print File" ), Details|Filler|User1|Cancel, User1, parent, name, true, true ),
m_item( item ), m_ip( QString::null ) /* will collect it in an instant */
{
setWFlags( Qt::WDestructiveClose );
if ( !m_item )
{
close();
}
setButtonGuiItem( User1, KStdGuiItem::print() );
setButtonText( Details, i18n( "Options" ) );
// Get the IP address
if ( Smb4KHostItem *host = Smb4KCore::scanner()->getHost( m_item->host(), m_item->workgroup() ) )
{
m_ip = host->ip();
}
// Bild the view:
QFrame *frame = plainPage();
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 10 );
QGroupBox *p = new QGroupBox( 2, Qt::Horizontal, i18n( "Printer" ), frame );
p->setInsideSpacing( 5 );
(void) new QLabel( i18n( "Name:" ), p );
(void) new QLabel( m_item->name()+
(!m_item->comment().stripWhiteSpace().isEmpty() ?
" ("+m_item->comment()+")" :
""), p );
// (void) new QLabel( i18n( "Comment:" ), p );
// (void) new QLabel( m_item->comment(), p );
(void) new QLabel( i18n( "Host:" ), p );
(void) new QLabel( m_item->host(), p );
(void) new QLabel( i18n( "IP address:" ), p );
(void) new QLabel( m_ip.stripWhiteSpace().isEmpty() ?
i18n( "Unknown" ) :
m_ip,
p );
(void) new QLabel( i18n( "Workgroup:" ), p );
(void) new QLabel( m_item->workgroup(), p );
QGroupBox *f = new QGroupBox( 2, Qt::Horizontal, i18n( "File" ), frame );
f->setInsideSpacing( 5 );
(void) new QLabel( i18n( "File:" ), f );
KURLRequester *requester = new KURLRequester( QString::null, f, "URL" );
requester->setMode( KFile::File | KFile::LocalOnly );
QGroupBox *s = new QGroupBox( 2, Qt::Horizontal, i18n( "Options" ), frame );
s->setInsideSpacing( 5 );
setDetailsWidget( s );
(void) new QLabel( i18n( "Copies:" ), s );
KIntNumInput *cp = new KIntNumInput( 1, s, 10, "Copies" );
cp->setMinValue( 1 );
layout->addWidget( p, 0, 0, 0 );
layout->addWidget( f, 1, 0, 0 );
setFixedSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
enableButton( User1, false );
connect( requester, SIGNAL( textChanged( const QString & ) ),
this, SLOT( slotInputValueChanged( const QString & ) ) );
}
Smb4KPrintDialog::~ Smb4KPrintDialog()
{
// Do not delete the pointer to the Smb4KShareObject here!
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KPrintDialog::slotUser1()
{
KURLRequester *url = static_cast<KURLRequester *>( child( "URL", "KURLRequester", true ) );
KIntNumInput *copies = static_cast<KIntNumInput *>( child( "Copies", "KIntNumInput", true ) );
if ( url && copies )
{
if ( !url->url().stripWhiteSpace().isEmpty() )
{
if ( Smb4KCore::print()->print( new Smb4KPrintInfo( m_item, m_ip, url->url().stripWhiteSpace(), copies->value() ) ) )
{
enableButton( User1, false );
connect( Smb4KCore::print(), SIGNAL( state( int ) ), this, SLOT( slotPrintStateChanged( int ) ) );
}
else
{
// FIXME: Should we report an error here?
}
}
else
{
KMessageBox::error( this, i18n( "You haven't specified a file." ) );
}
}
}
void Smb4KPrintDialog::slotCancel()
{
if ( Smb4KCore::printIsRunning() )
{
Smb4KCore::print()->abort();
}
KDialogBase::slotCancel();
}
void Smb4KPrintDialog::slotPrintStateChanged( int state )
{
switch ( state )
{
case PRINT_STOP:
{
accept();
break;
}
default:
{
break;
}
}
}
void Smb4KPrintDialog::slotInputValueChanged( const QString &text )
{
enableButton( User1, !text.isEmpty() );
}
#include "smb4kprintdialog.moc"

@ -0,0 +1,105 @@
/***************************************************************************
smb4kprintdialog - The print dialog for Smb4K
-------------------
begin : So Apr 11 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KPRINTDIALOG_H
#define SMB4KPRINTDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qstring.h>
// KDE includes
#include <kdialogbase.h>
// forward declarations
class Smb4KShareItem;
/**
* This class provides the print dialog for Smb4K. You can choose the
* file that is to be printed and you can define the number of copies
* you want to have.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KPrintDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param item The Smb4KShareItem of the printer.
*
* @param parent The parent widget of this dialog.
*
* @param name The name of this dialog.
*/
Smb4KPrintDialog( Smb4KShareItem *item, QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KPrintDialog();
protected slots:
/**
* Reimplemented from KDialogBase.
*/
void slotUser1();
/**
* Reimplemented from KDialogBase.
*/
void slotCancel();
/**
* This slot is connected to the Smb4KPrint::state() signal.
*/
void slotPrintStateChanged( int state );
/**
* This slot is being enabled if there is input text.
*
* @param text The input text.
*/
void slotInputValueChanged( const QString &text );
private:
/**
* The Smb4KShareItem object.
*/
Smb4KShareItem *m_item;
/**
* Holds the IP address.
*/
QString m_ip;
};
#endif

@ -0,0 +1,239 @@
/***************************************************************************
smb4ksynchronizationdialog - The synchronization dialog of Smb4K
-------------------
begin : Sa Mai 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qframe.h>
#include <qlabel.h>
// KDE includes
#include <klocale.h>
#include <kguiitem.h>
#include <kdebug.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <kprogress.h>
// application specific includes
#include "smb4ksynchronizationdialog.h"
#include "../core/smb4kshare.h"
#include "../core/smb4kcore.h"
#include "../core/smb4ksynchronizationinfo.h"
#include "../core/smb4ksettings.h"
Smb4KSynchronizationDialog::Smb4KSynchronizationDialog( Smb4KShare *share, QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Synchronization" ), User2|User1|Cancel, User1, parent, name, false, true ),
m_share( share )
{
setWFlags( Qt::WDestructiveClose );
setButtonGuiItem( User1, KGuiItem( i18n( "Synchronize" ), "bottom", i18n( "Synchronize the destination with the source" ) ) );
setButtonGuiItem( User2, KGuiItem( i18n( "Swap Paths" ), QString::null, i18n( "Swap source and destination" ) ) );
QFrame *frame = plainPage();
QGridLayout *layout = new QGridLayout( frame );
layout->setSpacing( 5 );
layout->setMargin( 0 );
QLabel *source_label = new QLabel( i18n( "Source:" ), frame, "SourceURLLabel" );
KURLRequester *source = new KURLRequester( m_share->path()+"/", frame, "SourceURL" );
source->setShowLocalProtocol( false );
source->setMode( KFile::Directory | KFile::LocalOnly );
QLabel *destination_label = new QLabel( i18n( "Destination:" ), frame, "DestinationURLLabel" );
KURLRequester *destination = new KURLRequester( Smb4KSettings::rsyncPrefix(), frame, "DestinationURL" );
destination->setShowLocalProtocol( false );
destination->setMode( KFile::Directory | KFile::LocalOnly );
KLineEdit *current_file = new KLineEdit( QString::null, frame, "ProgressInfo" );
current_file->setEnableSqueezedText( true );
current_file->setReadOnly( true );
KProgress *individual = new KProgress( frame, "IndividualProgress", 0 );
individual->setEnabled( false );
KProgress *total = new KProgress( frame, "TotalProgress", 0 );
total->setEnabled( false );
QWidget *transfer_widget = new QWidget( frame, "TransferInfoWidget" );
QGridLayout *trans_layout = new QGridLayout( transfer_widget );
trans_layout->setSpacing( 5 );
trans_layout->setMargin( 0 );
QLabel *file_label = new QLabel( i18n( "Files transferred:" ), transfer_widget,
"FilesTransferredLabel" );
QLabel *file_trans_label = new QLabel( "0 / 0", transfer_widget,
"FilesTransferred" );
QLabel *rate_label = new QLabel( i18n( "Transfer rate:" ), transfer_widget,
"TransferRateLabel" );
QLabel *trans_rate_label = new QLabel( "0.00 kB/s", transfer_widget,
"TransferRate" );
trans_layout->addWidget( file_label, 0, 0, 0 );
trans_layout->addWidget( file_trans_label, 0, 1, Qt::AlignRight );
trans_layout->addWidget( rate_label, 1, 0, 0 );
trans_layout->addWidget( trans_rate_label, 1, 1, Qt::AlignRight );
transfer_widget->setEnabled( false );
layout->addWidget( source_label, 0, 0, 0 );
layout->addWidget( source, 0, 1, 0 );
layout->addWidget( destination_label, 1, 0, 0 );
layout->addWidget( destination, 1, 1, 0 );
layout->addMultiCellWidget( current_file, 2, 2, 0, 1, 0 );
layout->addMultiCellWidget( individual, 3, 3, 0, 1, 0 );
layout->addMultiCellWidget( total, 4, 4, 0, 1, 0 );
layout->addMultiCellWidget( transfer_widget, 5, 6, 0, 1, 0 );
// Connections
connect( Smb4KCore::synchronizer(), SIGNAL( progress( const Smb4KSynchronizationInfo & ) ),
this, SLOT( slotProgress( const Smb4KSynchronizationInfo & ) ) );
connect( Smb4KCore::synchronizer(), SIGNAL( finished() ),
this, SLOT( slotSynchronizationFinished() ) );
setFixedSize( (sizeHint().width() > 350 ? sizeHint().width() : 350), sizeHint().height() );
}
Smb4KSynchronizationDialog::~Smb4KSynchronizationDialog()
{
// Do *not* delete the share object here.
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSynchronizationDialog::slotUser1()
{
// Synchronize!
// Disable the URL requesters but in a way, that the information
// proviced in them is still readable:
KURLRequester *source = static_cast<KURLRequester *>( child( "SourceURL", "KURLRequester", true ) );
source->lineEdit()->setReadOnly( true );
source->button()->setEnabled( false );
KURLRequester *destination = static_cast<KURLRequester *>( child( "DestinationURL", "KURLRequester", true ) );
destination->lineEdit()->setReadOnly( true );
destination->button()->setEnabled( false );
QWidget *transfer_widget = static_cast<QWidget *>( child( "TransferInfoWidget", "QWidget", true ) );
transfer_widget->setEnabled( true );
enableButton( User1, false );
enableButton( User2, false );
// Enable the progress bars and the information widgets:
static_cast<KProgress *>( child( "IndividualProgress", "KProgress", true ) )->setEnabled( true );
static_cast<KProgress *>( child( "TotalProgress", "KProgress", true ) )->setEnabled( true );
Smb4KCore::synchronizer()->synchronize( source->url(), destination->url() );
}
void Smb4KSynchronizationDialog::slotUser2()
{
// Swap URLs.
KURLRequester *source = static_cast<KURLRequester *>( child( "SourceURL", "KURLRequester", true ) );
KURLRequester *destination = static_cast<KURLRequester *>( child( "DestinationURL", "KURLRequester", true ) );
QString sourceURL = source->url();
QString destinationURL = destination->url();
source->setURL( destinationURL );
destination->setURL( sourceURL );
}
void Smb4KSynchronizationDialog::slotCancel()
{
Smb4KCore::synchronizer()->abort();
KDialogBase::slotCancel();
}
void Smb4KSynchronizationDialog::slotProgress( const Smb4KSynchronizationInfo &info )
{
KLineEdit *progress = static_cast<KLineEdit *>( child( "ProgressInfo", "KLineEdit", true ) );
KProgress *individual = static_cast<KProgress *>( child( "IndividualProgress", "KProgress", true ) );
KProgress *total = static_cast<KProgress *>( child( "TotalProgress", "KProgress", true ) );
QLabel *transferred = static_cast<QLabel *>( child( "FilesTransferred", "QLabel", true ) );
QLabel *rate = static_cast<QLabel *>( child( "TransferRate", "QLabel", true ) );
if ( !info.text().isEmpty() )
{
progress->setSqueezedText( info.text() );
}
if ( info.individualProgress() != -1 )
{
individual->setProgress( info.individualProgress() );
}
if ( info.totalProgress() != -1 )
{
total->setProgress( info.totalProgress() );
}
if ( info.totalFileNumber() != -1 && info.processedFileNumber() != -1 )
{
transferred->setText( QString( "%1 / %2" ).arg( info.processedFileNumber() ).arg( info.totalFileNumber() ) );
}
if ( !info.transferRate().isEmpty() )
{
rate->setText( info.transferRate() );
}
}
void Smb4KSynchronizationDialog::slotSynchronizationFinished()
{
KProgress *individual = static_cast<KProgress *>( child( "IndividualProgress", "KProgress", true ) );
KProgress *total = static_cast<KProgress *>( child( "TotalProgress", "KProgress", true ) );
if ( individual && individual->progress() != 100 )
{
individual->setProgress( 100 );
}
if ( total && total->progress() != 100 )
{
total->setProgress( 100 );
}
// Change the "Cancel" button to a "Close" button.
setButtonGuiItem( Cancel, KStdGuiItem::close() );
}
#include "smb4ksynchronizationdialog.moc"

@ -0,0 +1,111 @@
/***************************************************************************
smb4ksynchronizationdialog - The synchronization dialog of Smb4K
-------------------
begin : Sa Mai 19 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSYNCHRONIZATIONDIALOG_H
#define SMB4KSYNCHRONIZATIONDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kdialogbase.h>
#include <kurlrequester.h>
// forward declarations
class Smb4KShare;
class Smb4KSynchronizationInfo;
/**
* This class provides a synchronization dialog. It contains URL requesters
* for the source and destination as well as widgets to monitor the process
* of the synchronization.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSynchronizationDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* The constructor
*
* @param share The share item
*
* @param parent The parent widget
*
* @param name The name of this dialog
*/
Smb4KSynchronizationDialog( Smb4KShare *share, QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KSynchronizationDialog();
protected slots:
/**
* Reimplemented from KDialogBase. This slot starts the
* synchronization.
*/
void slotUser1();
/**
* Reimplemented from KDialogBase. This slot swaps the
* paths of the source and destination.
*/
void slotUser2();
/**
* Reimplemented from KDialogBase. This slot aborts the
* current synchronization and exists the dialog.
*/
void slotCancel();
/**
* This slot receives information about the progress of the
* current synchronization and puts it into the dialog.
*
* @param info Information about the progress of the
* current synchronization process.
*/
void slotProgress( const Smb4KSynchronizationInfo &info );
/**
* This slot is invoked when the synchronization has finished.
* It is connected to the Smb4KSynchronizer::finished() signal.
*/
void slotSynchronizationFinished();
private:
/**
* A pointer to the share object
*/
Smb4KShare *m_share;
};
#endif

@ -0,0 +1,22 @@
####### kdevelop will overwrite this part!!! (begin)##########
EXTRA_DIST = cr16-app-smb4k.png cr32-app-smb4k.png cr48-app-smb4k.png cr64-app-smb4k.png
install-data-local:
$(mkinstalldirs) $(kde_icondir)/crystalsvg/16x16/apps/
$(INSTALL_DATA) $(srcdir)/cr16-app-smb4k.png $(kde_icondir)/crystalsvg/16x16/apps/smb4k.png
$(mkinstalldirs) $(kde_icondir)/crystalsvg/32x32/apps/
$(INSTALL_DATA) $(srcdir)/cr32-app-smb4k.png $(kde_icondir)/crystalsvg/32x32/apps/smb4k.png
$(mkinstalldirs) $(kde_icondir)/crystalsvg/48x48/apps/
$(INSTALL_DATA) $(srcdir)/cr48-app-smb4k.png $(kde_icondir)/crystalsvg/48x48/apps/smb4k.png
$(mkinstalldirs) $(kde_icondir)/crystalsvg/64x64/apps/
$(INSTALL_DATA) $(srcdir)/cr64-app-smb4k.png $(kde_icondir)/crystalsvg/64x64/apps/smb4k.png
uninstall-local:
-rm -f $(kde_icondir)/crystalsvg/16x16/apps/smb4k.png
-rm -f $(kde_icondir)/crystalsvg/32x32/apps/smb4k.png
-rm -f $(kde_icondir)/crystalsvg/48x48/apps/smb4k.png
-rm -f $(kde_icondir)/crystalsvg/64x64/apps/smb4k.png
####### kdevelop will overwrite this part!!! (end)############

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,16 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = libsmb4ksharesiconview.la
libsmb4ksharesiconview_la_SOURCES = smb4ksharesiconview.cpp \
smb4ksharesiconview_part.cpp smb4ksharesiconviewitem.cpp \
smb4ksharesiconviewtooltip.cpp
libsmb4ksharesiconview_la_LDFLAGS = -module -no-undefined $(all_libraries)
noinst_HEADERS = smb4ksharesiconview.h smb4ksharesiconview_part.h \
smb4ksharesiconviewitem.h smb4ksharesiconviewtooltip.h
libsmb4ksharesiconview_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(top_builddir)/smb4k/dialogs/libsmb4kdialogs.la $(LIB_KIO) $(LIB_KDECORE) $(LIB_KDEUI) $(KDE_PLUGIN) $(LIB_KPARTS) \
$(LIB_QT)
partrcdir = $(kde_datadir)/smb4ksharesiconviewpart
partrc_DATA = smb4ksharesiconview_part.rc

@ -0,0 +1,271 @@
/***************************************************************************
smb4ksharesiconview - This is the shares icon view of Smb4K.
-------------------
begin : Mo Dez 4 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 <kdebug.h>
#include <kurl.h>
#include <kio/job.h>
#include <kdeversion.h>
// application specific includes
#include "smb4ksharesiconview.h"
#include "smb4ksharesiconviewitem.h"
#include "smb4ksharesiconviewtooltip.h"
#include "../core/smb4kshare.h"
#include "../core/smb4ksettings.h"
#include "../core/smb4kcore.h"
Smb4KSharesIconView::Smb4KSharesIconView( QWidget *parent, const char *name )
: KIconView( parent, name )
{
setSelectionMode( KIconView::Single ); // If this is changed, revise dragObject() function.
setResizeMode( KIconView::Adjust );
setAutoArrange( true );
setSorting( true, true );
setItemsMovable( false );
setAcceptDrops( true );
setItemTextPos( KIconView::Bottom );
setMaxItemWidth( 150 );
setArrangement( KIconView::LeftToRight );
setWordWrapIconText( true );
m_tooltip = NULL;
// Connections:
connect( this, SIGNAL( pressed( QIconViewItem * ) ),
this, SLOT( slotPressed( QIconViewItem * ) ) );
}
Smb4KSharesIconView::~Smb4KSharesIconView()
{
// The tool tip's parent is 0 and not this icon view.
if ( m_tooltip )
{
delete m_tooltip;
}
}
void Smb4KSharesIconView::updateToolTip()
{
if ( !m_tooltip )
{
return;
}
m_tooltip->update();
}
KURLDrag *Smb4KSharesIconView::dragObject()
{
// Get the KURL of the item that is to be dragged:
KURL url = KURL( static_cast<Smb4KSharesIconViewItem *>( currentItem() )->shareObject()->canonicalPath() );
KURLDrag *drag = new KURLDrag( KURL::List::List( url ), this );
drag->setPixmap( DesktopIcon( "folder" ) );
// drag->dragCopy();
return drag;
}
void Smb4KSharesIconView::startDrag()
{
// Kill the tooltip, so it is not in the way:
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
if ( !Smb4KSettings::enableDragSupport() )
{
return;
}
KIconView::startDrag();
}
void Smb4KSharesIconView::contentsDragEnterEvent( QDragEnterEvent *e )
{
e->accept( Smb4KSettings::enableDropSupport() );
}
void Smb4KSharesIconView::contentsDragMoveEvent( QDragMoveEvent *e )
{
QIconViewItem *item = findItem( e->pos() );
e->accept( Smb4KSettings::enableDropSupport() && item );
}
void Smb4KSharesIconView::contentsDropEvent( QDropEvent *e )
{
QIconViewItem *item = findItem( e->pos() );
KURL::List src;
// Do we have to stop here?
if ( !Smb4KSettings::enableDropSupport() ||
!item ||
!KURLDrag::decode( e, src ) )
{
e->ignore();
return;
}
KURL dest;
dest.setPath( static_cast<Smb4KSharesIconViewItem *>( item )->shareObject()->canonicalPath() );
// Deny dropping if we dropped something on itself.
// This was inspired by KonqOperations::doDrop() function.
for ( KURL::List::Iterator it = src.begin(); it != src.end(); ++it )
{
if ( dest.equals( *it, true ) )
{
if ( e->source() == this || e->source()->parent() == this )
{
e->ignore();
return;
}
}
}
// We only allow copying:
KIO::CopyJob *job = KIO::copy( src, dest, true );
job->setAutoErrorHandlingEnabled( true, NULL );
#if KDE_VERSION_MAJOR >= 3 && KDE_VERSION_MINOR >= 5
job->setAutoWarningHandlingEnabled( true );
#endif
}
void Smb4KSharesIconView::contentsMouseMoveEvent( QMouseEvent *e )
{
m_pos = e->globalPos();
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( findItem( e->pos() ) );
if ( item )
{
if ( m_tooltip )
{
// Check if tool tip is still valid:
if ( m_tooltip->item() != item )
{
delete m_tooltip;
if ( hasMouse() && Smb4KSettings::showShareToolTip() )
{
m_tooltip = new Smb4KSharesIconViewToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
m_tooltip = NULL;
}
}
else
{
// Do nothing
}
}
else
{
// Create new tool tip:
if ( hasMouse() && Smb4KSettings::showShareToolTip() )
{
m_tooltip = new Smb4KSharesIconViewToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
// Do nothing
}
}
}
else
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
}
KIconView::contentsMouseMoveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesIconView::slotPressed( QIconViewItem *item )
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
if ( !item )
{
// Clear the selection if the user clicked onto the
// viewport:
clearSelection();
}
else
{
// Do nothing
}
}
void Smb4KSharesIconView::slotShowToolTip()
{
if ( m_tooltip && hasMouse() && Smb4KSettings::showShareToolTip() &&
(m_tooltip->item() == static_cast<Smb4KSharesIconViewItem *>( findItem( viewport()->mapFromGlobal( m_pos ) ) )) )
{
m_tooltip->showTip( m_pos );
}
else
{
delete m_tooltip;
m_tooltip = NULL;
}
}
#include "smb4ksharesiconview.moc"

@ -0,0 +1,139 @@
/***************************************************************************
smb4ksharesiconview - This is the shares icon view of Smb4K.
-------------------
begin : Mo Dez 4 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESICONVIEW_H
#define SMB4KSHARESICONVIEW_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qvaluelist.h>
// KDE includes
#include <kiconview.h>
#include <kurldrag.h>
// forward declarations
class Smb4KSharesIconViewItem;
class Smb4KSharesIconViewToolTip;
/**
* This widget class provides the shares icon view of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesIconView : public KIconView
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget
*
* @param name The name of the widget
*/
Smb4KSharesIconView( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KSharesIconView();
/**
* Update the tool tip if it exists. This function just executes
* Smb4KSharesListViewToolTip::update().
*/
void updateToolTip();
protected:
/**
* Reimplemented (sort of) from QIconView to enable dragging. As QDragObject
* a KURLDrag will be returned.
*
* @returns a KURLDrag object.
*/
KURLDrag *dragObject();
/**
* Reimplemented from QIconView to allow some actions to be carried
* out before the drag begins.
*/
void startDrag();
/**
* Reimplemented from QIconView.
*/
void contentsDragEnterEvent( QDragEnterEvent * );
/**
* Reimplemented from QIconView.
*/
void contentsDragMoveEvent( QDragMoveEvent *e );
/**
* Reimplemented from QIconView.
*/
void contentsDropEvent( QDropEvent *e );
/**
* Reimplemented from QIconView. This function is used to
* show the tooltips.
*/
void contentsMouseMoveEvent( QMouseEvent *e );
protected slots:
/**
* This slot is connected to KIconView::pressed() and clears the selection
* if the user clicked on the viewport.
*
* @param item The QIconViewItem that the user clicked or NULL
* if he/she pressed a mouse button on the viewport.
*/
void slotPressed( QIconViewItem *item );
/**
* This slot shows the tool tip for an icon view item.
*/
void slotShowToolTip();
private:
/**
* The current global mouse position
*/
QPoint m_pos;
/**
* The tool tip
*/
Smb4KSharesIconViewToolTip *m_tooltip;
};
#endif

@ -0,0 +1,573 @@
/***************************************************************************
smb4ksharesview_part - This Part includes the shares icon view
of Smb4K.
-------------------
begin : Mo Dez 4 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 <kglobal.h>
#include <kstdaction.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kaction.h>
#include <kshortcut.h>
#include <kdebug.h>
#include <kpopupmenu.h>
#include <kiconloader.h>
#include <kactionclasses.h>
// application specific includes
#include "smb4ksharesiconview_part.h"
#include "smb4ksharesiconview.h"
#include "smb4ksharesiconviewitem.h"
#include "../dialogs/smb4ksynchronizationdialog.h"
#include "../core/smb4kshare.h"
#include "../core/smb4kcore.h"
#include "../core/smb4ksettings.h"
KInstance *Smb4KSharesIconViewPartFactory::m_instance = 0L;
KAboutData *Smb4KSharesIconViewPartFactory::m_about = 0L;
Smb4KSharesIconViewPart::Smb4KSharesIconViewPart( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name )
: KParts::Part( parent, name )
{
// First of all We need an instance:
setInstance( Smb4KSharesIconViewPartFactory::instance() );
// Set the XML file:
setXMLFile( "smb4ksharesiconview_part.rc" );
// Set the widget of this part:
m_widget = new Smb4KSharesIconView( parentWidget, widgetName );
setWidget( m_widget );
// Set up the actions.
// Do not put this before setWidget() or the shortcuts
// will not be shown.
setupActions();
// Import the shares:
slotMountedShares();
// Load settings:
loadSettings();
// Add some connections:
connect( Smb4KCore::mounter(), SIGNAL( updated() ),
this, SLOT( slotMountedShares() ) );
connect( Smb4KCore::synchronizer(), SIGNAL( state( int ) ),
this, SLOT( slotSynchronizationState( int ) ) );
connect( m_widget, SIGNAL( contextMenuRequested( QIconViewItem *, const QPoint & ) ),
this, SLOT( slotContextMenuRequested( QIconViewItem *, const QPoint & ) ) );
connect( m_widget, SIGNAL( selectionChanged( QIconViewItem * ) ),
this, SLOT( slotSelectionChanged( QIconViewItem * ) ) );
connect( m_widget, SIGNAL( pressed( QIconViewItem * ) ),
this, SLOT( slotMouseButtonPressed( QIconViewItem * ) ) );
connect( m_widget, SIGNAL( executed( QIconViewItem * ) ),
this, SLOT( slotFilemanager() ) );
}
Smb4KSharesIconViewPart::~Smb4KSharesIconViewPart()
{
}
void Smb4KSharesIconViewPart::setupActions()
{
// Create the actions:
KAction *unmount = new KAction( i18n( "&Unmount" ), "hdd_unmount", KShortcut( CTRL+Key_U ),
this, SLOT( slotUnmountShare() ),
actionCollection(), "unmount_action" );
#ifdef __linux__
KAction *force = new KAction( i18n( "&Force Unmounting" ), "hdd_unmount", KShortcut( CTRL+Key_F ),
this, SLOT( slotForceUnmountShare() ),
actionCollection(), "force_unmount_action" );
#endif
KAction *all = new KAction( i18n( "U&nmount All" ), "gear", KShortcut( CTRL+Key_N ),
this, SLOT( slotUnmountAllShares() ),
actionCollection(), "unmount_all_action" );
KAction *sync = new KAction( i18n( "S&ynchronize" ), "bottom", KShortcut( CTRL+Key_Y ),
this, SLOT( slotSynchronize() ),
actionCollection(), "synchronize_action" );
KAction *konsole = new KAction( i18n( "Open with Konso&le" ), "terminal", KShortcut( CTRL+Key_L ),
this, SLOT( slotKonsole() ),
actionCollection(), "konsole_action" );
KAction *konq = new KAction( i18n( "Open with &Konqueror" ), "kfm_home", KShortcut( CTRL+Key_K ),
this, SLOT( slotFilemanager() ),
actionCollection(), "filemanager_action" );
// Disable all actions for now:
unmount->setEnabled( false );
#ifdef __linux__
force->setEnabled( false );
#endif
all->setEnabled( false );
sync->setEnabled( false );
konsole->setEnabled( false );
konq->setEnabled( false );
// Insert the actions into the menu:
m_menu = new KActionMenu( this, "SharesIconViewMenu" );
m_menu->popupMenu()->insertTitle( SmallIcon( "hdd_mount" ), i18n( "Shares" ), 0 );
m_menu->insert( unmount, -1 );
#ifdef __linux__
m_menu->insert( force, -1 );
#endif
m_menu->insert( all, -1 );
m_menu->popupMenu()->insertSeparator( -1 );
m_menu->insert( sync, -1 );
m_menu->popupMenu()->insertSeparator( -1 );
m_menu->insert( konsole, -1 );
m_menu->insert( konq, -1 );
}
void Smb4KSharesIconViewPart::loadSettings()
{
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() );
#endif
// Change the text of the share:
for ( QIconViewItem *it = m_widget->firstItem(); it; it = it->nextItem() )
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( it );
if ( item )
{
item->setText( (Smb4KSettings::showMountPoint() ?
item->shareObject()->path() :
item->shareObject()->name()) );
}
}
// Enable/disable support for dropping:
m_widget->setAcceptDrops( Smb4KSettings::enableDropSupport() );
// Load or remove all foreign shares. The easiest way to do this
// is to invoke slotMountedShares():
slotMountedShares();
}
void Smb4KSharesIconViewPart::customEvent( QCustomEvent *e )
{
switch ( e->type() )
{
case EVENT_LOAD_SETTINGS:
{
loadSettings();
slotMountedShares();
break;
}
case EVENT_SET_FOCUS:
{
KIconView *view = static_cast<KIconView *>( m_widget );
if ( view->count() != 0 )
{
view->setSelected( !view->currentItem() ?
view->firstItem() :
view->currentItem(), true, false );
}
view->setFocus();
break;
}
default:
{
break;
}
}
KParts::Part::customEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS (Smb4KSharesIconViewPart)
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesIconViewPart::slotContextMenuRequested( QIconViewItem *item, const QPoint &pos )
{
if ( item )
{
m_menu->popupMenu()->changeTitle( 0, SmallIcon( "hdd_mount" ),
static_cast<Smb4KSharesIconViewItem *>( item )->shareObject()->name() );
}
else
{
m_menu->popupMenu()->changeTitle( 0, SmallIcon( "hdd_mount" ), i18n( "Shares" ) );
}
m_menu->popupMenu()->exec( pos, 0 );
}
void Smb4KSharesIconViewPart::slotSelectionChanged( QIconViewItem *item )
{
// NOTE: Here we only enable or disable the KActions. All other things
// are done in the Smb4KSharesIconView class.
// This slot is used to enable or disable the actions when the user
// changes the item in the icon view. This slot won't be called when
// the user clicks on the view port!
if ( item )
{
actionCollection()->action( "unmount_action" )->setEnabled( true );
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() );
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( true );
Smb4KShare *share = static_cast<Smb4KSharesIconViewItem *>( item )->shareObject();
if ( !share->isBroken() )
{
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() );
actionCollection()->action( "filemanager_action" )->setEnabled( true );
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
!Smb4KCore::synchronizer()->isRunning() );
}
else
{
actionCollection()->action( "konsole_action" )->setEnabled( false );
actionCollection()->action( "filemanager_action" )->setEnabled( false );
actionCollection()->action( "synchronize_action" )->setEnabled( false );
}
}
else
{
// Smb4KSharesIconViewPart::slotMouseButtonPressed()
}
}
void Smb4KSharesIconViewPart::slotMouseButtonPressed( QIconViewItem *item )
{
// NOTE: Here we only enable or disable the KActions. All other things
// are done in the Smb4KSharesIconView class.
// Here we do all the stuff that cannot be done in
// Smb4KSharesIconViewPart::slotSelectionChanged()
if ( !item )
{
actionCollection()->action( "unmount_action" )->setEnabled( false );
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( false );
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( (m_widget->count() > 0) );
actionCollection()->action( "konsole_action" )->setEnabled( false );
actionCollection()->action( "filemanager_action" )->setEnabled( false );
actionCollection()->action( "synchronize_action" )->setEnabled( false );
}
else
{
// See Smb4KSharesIconViewPart::slotSelectionChanged()
}
}
void Smb4KSharesIconViewPart::slotMountedShares()
{
// Get the list of shares:
QValueList<Smb4KShare *> list = Smb4KCore::mounter()->getShares();
// Update the view:
if ( !list.isEmpty() )
{
// Remove all obsolete items:
Smb4KSharesIconViewItem *test_item = static_cast<Smb4KSharesIconViewItem *>( m_widget->firstItem() );
Smb4KSharesIconViewItem *next_item = NULL;
while ( test_item )
{
Smb4KShare *share = Smb4KCore::mounter()->findShareByPath( test_item->shareObject()->path() );
next_item = static_cast<Smb4KSharesIconViewItem *>( test_item->nextItem() );
if( !share || (test_item->shareObject()->isForeign() && !Smb4KSettings::showAllShares()) )
{
delete test_item;
test_item = NULL;
}
test_item = next_item;
}
// Now process the entries in the list:
bool already_in_view = false;
for ( QValueListConstIterator<Smb4KShare *> it = list.begin(); it != list.end(); ++it )
{
// Check, whether the share is already in the list. Look for the
// mount point.
for ( Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->firstItem() );
item; item = static_cast<Smb4KSharesIconViewItem *>( item->nextItem() ) )
{
if ( QString::compare( item->shareObject()->path(), (*it)->path() ) == 0 ||
QString::compare( item->shareObject()->canonicalPath(), (*it)->canonicalPath() ) == 0 )
{
// Replace the share object if something changed:
if ( !item->sameShareObject( *it ) )
{
item->replaceShareObject( *it );
}
already_in_view = true;
break;
}
else
{
continue;
}
}
if ( !already_in_view )
{
if ( !Smb4KSettings::showAllShares() && (*it)->isForeign() )
{
// If the user does not want to have foreign shares
// displayed continue.
continue;
}
else
{
// Put the new item into the icon view:
(void) new Smb4KSharesIconViewItem( *it, Smb4KSettings::showMountPoint(), m_widget );
continue;
}
}
already_in_view = false;
}
m_widget->sort( m_widget->sortDirection() );
}
else
{
m_widget->clear();
}
// Update the tool tip, if it exists:
if ( m_widget->count() != 0 )
{
m_widget->updateToolTip();
}
// Enable/disable the actions:
QIconViewItem *item = m_widget->currentItem();
bool have_selected_item = (item && item->isSelected());
actionCollection()->action( "unmount_action" )->setEnabled( have_selected_item );
#ifdef __linux__
if ( Smb4KSettings::useForceUnmount() )
{
actionCollection()->action( "force_unmount_action" )->setEnabled( have_selected_item );
}
else
{
actionCollection()->action( "force_unmount_action" )->setEnabled( false );
}
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( (m_widget->count() > 0) );
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() &&
have_selected_item );
actionCollection()->action( "filemanager_action" )->setEnabled( have_selected_item );
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
!Smb4KCore::synchronizer()->isRunning() &&
have_selected_item );
}
void Smb4KSharesIconViewPart::slotUnmountShare()
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->currentItem() );
if ( item )
{
Smb4KCore::mounter()->unmountShare( item->shareObject(), false );
}
}
void Smb4KSharesIconViewPart::slotForceUnmountShare()
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->currentItem() );
if ( item )
{
Smb4KCore::mounter()->unmountShare( item->shareObject(), true );
}
}
void Smb4KSharesIconViewPart::slotUnmountAllShares()
{
Smb4KCore::mounter()->unmountAllShares();
}
void Smb4KSharesIconViewPart::slotSynchronize()
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->currentItem() );
Smb4KSynchronizationDialog *dlg = static_cast<Smb4KSynchronizationDialog *>( m_widget->child( "SynchronizationDialog", "Smb4KSynchronizationDialog", true ) );
if ( item && !item->shareObject()->isBroken() && !dlg )
{
dlg = new Smb4KSynchronizationDialog( item->shareObject(), m_widget, "SynchronizationDialog" );
dlg->show();
}
}
void Smb4KSharesIconViewPart::slotKonsole()
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->currentItem() );
if ( item && !item->shareObject()->isBroken() )
{
Smb4KCore::open( item->shareObject(), Smb4KCore::Konsole );
}
}
void Smb4KSharesIconViewPart::slotFilemanager()
{
Smb4KSharesIconViewItem *item = static_cast<Smb4KSharesIconViewItem *>( m_widget->currentItem() );
if ( item )
{
// Workaround: The item is not selected if you execute it, so
// we have to do it here:
// item->setSelected( true );
if ( !item->shareObject()->isBroken() )
{
Smb4KCore::open( item->shareObject(), Smb4KCore::Konqueror );
}
}
}
void Smb4KSharesIconViewPart::slotSynchronizationState( int state )
{
switch ( state )
{
case SYNCHRONIZER_START:
{
actionCollection()->action( "synchronize_action" )->setEnabled( false );
break;
}
case SYNCHRONIZER_STOP:
{
actionCollection()->action( "synchronize_action" )->setEnabled( true );
break;
}
default:
{
break;
}
}
}
/////////////////////////////////////////////////////////////////////////////
// FACTORY STUFF
/////////////////////////////////////////////////////////////////////////////
Smb4KSharesIconViewPartFactory::Smb4KSharesIconViewPartFactory()
: KParts::Factory()
{
}
Smb4KSharesIconViewPartFactory::~Smb4KSharesIconViewPartFactory()
{
delete m_instance;
delete m_about;
m_instance = 0L;
}
KParts::Part *Smb4KSharesIconViewPartFactory::createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name, const char *, const QStringList & )
{
Smb4KSharesIconViewPart *obj = new Smb4KSharesIconViewPart( parentWidget, widgetName, parent, name );
// See if we are to be read-write or not
// if (QCString(classname) == "KParts::ReadOnlyPart")
// {
// obj->setReadWrite(false);
// }
return obj;
}
KInstance *Smb4KSharesIconViewPartFactory::instance()
{
if( !m_instance )
{
m_about = new KAboutData( "smb4ksharesiconviewpart", I18N_NOOP( "Smb4KSharesIconViewPart" ), "1.0" );
m_about->addAuthor("Alexander Reinholdt", 0, "dustpuppy@users.berlios.de");
m_about->setLicense( KAboutData::License_GPL );
m_instance = new KInstance( m_about );
}
return m_instance;
}
/////////////////////////////////////////////////////////////////////////////
// INIT
/////////////////////////////////////////////////////////////////////////////
extern "C"
{
void *init_libsmb4ksharesiconview()
{
KGlobal::locale()->insertCatalogue( "smb4k" );
return new Smb4KSharesIconViewPartFactory;
}
}
#include "smb4ksharesiconview_part.moc"

@ -0,0 +1,232 @@
/***************************************************************************
smb4ksharesview_part - This Part includes the shares icon view
of Smb4K.
-------------------
begin : Mo Dez 4 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESICONVIEW_PART_H
#define SMB4KSHARESICONVIEW_PART_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kparts/part.h>
#include <kparts/factory.h>
// applications specific includes
#include "smb4ksharesiconview.h"
/**
* This is one of the parts of Smb4K. It contains the shares icon
* view.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesIconViewPart : public KParts::Part
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parentWidget The parent widget
*
* @param widgetName The name the widget should have
*
* @param parent The parent object
*
* @param name The name this object should have
*/
Smb4KSharesIconViewPart( QWidget *parentWidget = 0, const char *widgetName = 0,
QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
virtual ~Smb4KSharesIconViewPart();
protected:
/**
* Reimplemented from KParts::Part.
*/
void customEvent( QCustomEvent *e );
protected slots:
/**
* Opens a context menu over the icon view item @p item at position
* @p pos if requested.
*
* @param item The icon view item or NULL if the user clicked
* somewhere else.
*
* @param pos The position where the user clicked.
*/
void slotContextMenuRequested( QIconViewItem *item, const QPoint & pos );
/**
* This slot is called when the selection in the icon view changed. It
* enables or disables the actions according to known options/states.
* Please note that it won't be invoked when the user clicked on the
* viewport. Use slotMouseButtonPressed() to also catch that event.
*
* @param item The icon view item that was selected
*/
void slotSelectionChanged( QIconViewItem *item );
/**
* This slot is called when the user presses any mouse button somewhere
* in the icon view. It enables or disables the actions according to known
* options/states.
*
* @param item The icon view item that was clicked or NULL if the
* user clicked onto the viewport.
*/
void slotMouseButtonPressed( QIconViewItem *item );
/**
* This slot is called by the Smb4KMounter::updated() signal and updates
* the icon view according to the list that is returned by Smb4KMounter::getShares().
*/
void slotMountedShares();
/**
* This slot is connected to the 'Unmount action'. You will be able to
* unmount a certain share when activating this slot.
*/
void slotUnmountShare();
/**
* This slot is connected to the 'Force Unmounting' action and is, thus,
* only useful under Linux, because only there the possibility for a forced
* (i.e. lazy) unmount exists.
*
* When activating this slot, the selected share will be unmounted, even if
* it is not accessible or the server already went offline.
*/
void slotForceUnmountShare();
/**
* This slot is connected to the 'Unmount All' action. All shares - either of
* the user or that are present on the system (depending on the settings the
* user chose) - will be unmounted. Please note that Smb4KMounter::unmountAllShares()
* is invoked directly.
*/
void slotUnmountAllShares();
/**
* This slot is connected to the 'Synchronize' action. The current item will be
* synchronized with a local copy (or vice versa) if you activate it.
*/
void slotSynchronize();
/**
* This slot is connected to the 'Konsole' action. The mount point of the current
* share item will be opened in Konsole.
*/
void slotKonsole();
/**
* This slot is connected to the 'Konqueror' action. The contents of the current
* share item will be opened in the file manager.
*/
void slotFilemanager();
/**
* This slot is called by the synchronizer whenever the state of the synchronization
* process changed.
*
* @param state The state the synchronizer is in.
*/
void slotSynchronizationState( int state );
private:
/**
* Set up the actions
*/
void setupActions();
/**
* Load settings for the widget or the actions.
*/
void loadSettings();
/**
* The icon view.
*/
Smb4KSharesIconView *m_widget;
/**
* The action menu.
*/
KActionMenu *m_menu;
};
class KInstance;
class KAboutData;
class Smb4KSharesIconViewPartFactory : public KParts::Factory
{
Q_OBJECT
public:
/**
* The constructor
*/
Smb4KSharesIconViewPartFactory();
/**
* The destructor
*/
virtual ~Smb4KSharesIconViewPartFactory();
/**
* Reimplemented from KParts::Factory
*/
virtual KParts::Part *createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const char *classname, const QStringList &args );
/**
* The instance
*/
static KInstance *instance();
private:
/**
* The factory's instance.
*/
static KInstance *m_instance;
/**
* The factory's KAboutData object
*/
static KAboutData *m_about;
};
#endif

@ -0,0 +1,25 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="smb4ksharesiconview_part" version="1">
<MenuBar>
<Menu name="shares"><text>&amp;Shares</text>
<Action name="unmount_action"/>
<Action name="force_unmount_action"/>
<Action name="unmount_all_action"/>
<Separator/>
<Action name="synchronize_action"/>
<Separator/>
<Action name="konsole_action"/>
<Action name="filemanager_action"/>
</Menu>
</MenuBar>
<ToolBar name="sharesViewToolBar">
<Action name="unmount_action"/>
<Action name="force_unmount_action"/>
<Action name="unmount_all_action"/>
<Separator/>
<Action name="synchronize_action"/>
<Separator/>
<Action name="konsole_action"/>
<Action name="filemanager_action"/>
</ToolBar>
</kpartgui>

@ -0,0 +1,148 @@
/***************************************************************************
smb4ksharesiconviewitem - The items for Smb4K's shares icon view.
-------------------
begin : Di Dez 5 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qpixmap.h>
// KDE includes
#include <kiconeffect.h>
#include <kdebug.h>
// application specific includes
#include "smb4ksharesiconviewitem.h"
#include "smb4ksharesiconview.h"
Smb4KSharesIconViewItem::Smb4KSharesIconViewItem( Smb4KShare *share, bool mountpoint,
Smb4KSharesIconView *parent )
: KIconViewItem( parent, QString::null ), m_share( *share ), m_mountpoint( mountpoint ),
m_initial_setup( false )
{
setDropEnabled( true );
setDragEnabled( true );
m_loader = new KIconLoader();
setupItem( m_share, m_mountpoint );
}
Smb4KSharesIconViewItem::~Smb4KSharesIconViewItem()
{
// Do not touch the Smb4KShare object!
delete m_loader;
}
void Smb4KSharesIconViewItem::paintItem( QPainter *p, const QColorGroup &cg )
{
// Set the color of the item text:
QColorGroup colorgrp( cg );
if ( m_share.isForeign() )
{
colorgrp.setColor( QColorGroup::Text, Qt::gray );
}
QIconViewItem::paintItem( p, colorgrp );
}
bool Smb4KSharesIconViewItem::acceptDrop( const QMimeSource *source ) const
{
if ( source->provides( "text/plain" ) )
{
return true;
}
return false;
}
void Smb4KSharesIconViewItem::setupItem( const Smb4KShare &share, bool mountpoint )
{
// Only do something here if either the item hasn't been set up
// yet, or share and mountpoint changed, respectively.
if ( !m_initial_setup || !m_share.equals( share ) || m_mountpoint != mountpoint )
{
if ( !m_initial_setup || m_share.isBroken() != share.isBroken() )
{
int icon_state = m_share.isForeign() ? KIcon::DisabledState : KIcon::DefaultState;
if ( m_share.isBroken() )
{
QImage over = m_loader->loadIcon( "button_cancel", KIcon::Desktop,
0, icon_state, 0L, false ).convertToImage();
QImage src = m_loader->loadIcon( "hdd_mount", KIcon::Desktop,
0, icon_state, 0L, false ).convertToImage();
KIconEffect e;
e.semiTransparent( over );
e.overlay( src, over );
m_pixmap = QPixmap( src );
}
else
{
m_pixmap = m_loader->loadIcon( "hdd_mount", KIcon::Desktop,
0, icon_state, 0L, false );
}
setPixmap( m_pixmap );
}
else
{
// Do nothing
}
if ( !m_initial_setup || m_mountpoint != mountpoint )
{
setText( (m_mountpoint ? m_share.path() : m_share.name()) );
}
else
{
// Do nothing
}
m_initial_setup = true;
m_share = share;
m_mountpoint = mountpoint;
}
else
{
// Do nothing
}
}
bool Smb4KSharesIconViewItem::sameShareObject( Smb4KShare *share )
{
return m_share.equals( *share );
}
void Smb4KSharesIconViewItem::replaceShareObject( Smb4KShare *share )
{
setupItem( *share, m_mountpoint );
}

@ -0,0 +1,173 @@
/***************************************************************************
smb4ksharesiconviewitem - The items for Smb4K's shares icon view.
-------------------
begin : Di Dez 5 2006
copyright : (C) 2006 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESICONVIEWITEM_H
#define SMB4KSHARESICONVIEWITEM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qpainter.h>
#include <qpalette.h>
// KDE includes
#include <kiconview.h>
#include <kiconloader.h>
// application specific includes
#include "../core/smb4kshare.h"
// forward declarations
class Smb4KSharesIconView;
/**
* This class provides the items for the shares icon view
* of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesIconViewItem : public KIconViewItem
{
public:
/**
* The constructor.
*
* @param share The Smb4KShare object that represents the share.
*
* @param mountpoint Tells the item if the mount point instead of the
* share name should be shown. Default is FALSE.
*
* @param parent The parent widget of this item.
*/
Smb4KSharesIconViewItem( Smb4KShare *share,
bool mountpoint = false,
Smb4KSharesIconView *parent = 0 );
/**
* The destructor
*/
~Smb4KSharesIconViewItem();
/**
* This function compares the encapsulated Smb4KShare object with @p item
* and returns TRUE if they contain equal values.
*
* @param item A Smb4KShare object that should be compared
*
* @returns TRUE if @p item has the same values stored as the
* encapsulated Smb4KShare object.
*/
bool sameShareObject( Smb4KShare *share );
/**
* Replace the encapsulated Smb4KShare object. This function just passes
* the share object to setupItem() which does all the work.
*
* @param share The new Smb4KShare object
*/
void replaceShareObject( Smb4KShare *share );
/**
* Returns a pointer to the share object that's represented by this item.
* You have to use it to access its data.
*
* @returns a pointer to a Smb4KShare object.
*/
Smb4KShare *shareObject() { return &m_share; }
/**
* This function returns the desktop pixmap of this item.
*
* @returns the destop pixmap of this item.
*/
const QPixmap &desktopPixmap() { return m_pixmap; }
protected:
/**
* Reimplemented from QIconViewItem.
*
* This function paints the icon text and uses Smb4KShare::isForeign() to
* determine the color (TRUE: gray, FALSE: the default color).
*
* @param p The painter
*
* @param cg The color group
*/
void paintItem( QPainter *p,
const QColorGroup &cg );
/**
* Reimplemented from QIconViewItem.
*
* This function accepts or denies drops according to the contents of @p source.
*
* @param source The mime source
*/
bool acceptDrop( const QMimeSource *source ) const;
private:
/**
* Set up the icon and text of the item with resepect to @p share and @p mountpoint.
*
* @param share The Smb4KShare object.
*
* @param mountpoint If TRUE, the mount point will be shown instead of the
* share name.
*/
void setupItem( const Smb4KShare &share,
bool mountpoint = false );
/**
* The Smb4KShare object representing the share.
*/
Smb4KShare m_share;
/**
* Tells us if the mount point instead of the share
* name should be shown.
*/
bool m_mountpoint;
/**
* Tells us that the initial setup already happened.
*/
bool m_initial_setup;
/**
* The icon loader for this item.
*/
KIconLoader *m_loader;
/**
* The desktop pixmap
*/
QPixmap m_pixmap;
};
#endif

@ -0,0 +1,429 @@
/***************************************************************************
smb4ksharesiconviewtooltip - Tool tip for the shares icon view.
-------------------
begin : Do Jan 4 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qtooltip.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qtimer.h>
// KDE includes
#include <klocale.h>
#include <kdebug.h>
// application specific includes
#include "smb4ksharesiconviewtooltip.h"
#include "smb4ksharesiconviewitem.h"
Smb4KSharesIconViewToolTip::Smb4KSharesIconViewToolTip( Smb4KSharesIconViewItem *item )
: QLabel( 0, "SharesIconViewToolTip", WStyle_StaysOnTop | WStyle_Customize |
WStyle_NoBorder | WStyle_Tool | WX11BypassWM | WDestructiveClose ), m_item( item )
{
setPalette( QToolTip::palette() );
setLineWidth( 1 );
setMidLineWidth( 1 );
setFrameShape( Box );
setFrameShadow( Plain );
setMouseTracking( true );
m_layout = new QGridLayout( this );
m_layout->setMargin( 10 );
m_layout->setSpacing( 3 );
m_is_set_up = false;
m_free = NULL;
m_used = NULL;
m_total = NULL;
m_usage = NULL;
m_pixmap = NULL;
// We will set up the tip in the showTip() function.
}
Smb4KSharesIconViewToolTip::~Smb4KSharesIconViewToolTip()
{
// Never touch the Smb4KSharesIconViewItem object here!
}
void Smb4KSharesIconViewToolTip::showTip( const QPoint &pos )
{
if ( !m_item || isShown() )
{
return;
}
setupTip();
adjustSize();
QDesktopWidget *d = QApplication::desktop();
QPoint p( pos );
if ( p.x() + width() > d->width() )
{
p.setX( p.x() - width() - 5 );
}
else
{
p.setX( p.x() + 5 );
}
if ( p.y() + height() > d->height() )
{
p.setY( p.y() - height() - 5 );
}
else
{
p.setY( p.y() + 5 );
}
setGeometry( p.x(), p.y(), width(), height() );
polish();
show();
QTimer::singleShot( 10000, this, SLOT( slotHideToolTip() ) );
}
void Smb4KSharesIconViewToolTip::setupTip()
{
if ( !m_item )
{
return;
}
m_layout->addWidget( new QLabel( i18n( "Share:" ), this ), 0, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->name(), this ), 0, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Mount point:" ), this ), 1, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->path(), this ), 1, 2, 0 );
if ( QString::compare( m_item->shareObject()->filesystem(), "smbfs" ) == 0 )
{
m_layout->addWidget( new QLabel( "Owner:", this ), 2, 1, 0 );
m_layout->addWidget( new QLabel( QString( "%1 - %2" ).arg( m_item->shareObject()->user(), m_item->shareObject()->group() ), this ), 2, 2, 0 );
}
else
{
m_layout->addWidget( new QLabel( "Login:", this ), 2, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->cifsLogin(), this ), 2, 2, 0 );
}
m_layout->addWidget( new QLabel( i18n( "File system:" ), this ), 3, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->filesystem().upper(), this ), 3, 2, 0 );
QFrame *line = new QFrame( this );
line->setLineWidth( 1 );
line->setMidLineWidth( 0 );
line->setFixedWidth( 100 );
line->setFrameShape( QFrame::HLine );
line->setFrameShadow( QFrame::Plain );
m_layout->addMultiCellWidget( line, 4, 4, 1, 2, Qt::AlignCenter );
// Prepare the disk usage stuff.
if ( !m_item->shareObject()->isBroken() )
{
QString total, free, used, total_dim, free_dim, used_dim;
if ( m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( m_item->shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = m_item->shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( m_item->shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( m_item->shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = m_item->shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( m_item->shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
m_layout->addWidget( new QLabel( i18n( "Free:" ), this, "FreeLabel" ), 5, 1, 0 );
m_free = new QLabel( QString( "%1 %2" ).arg( free, free_dim ), this );
m_layout->addWidget( m_free, 5, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Used:" ), this, "UsedLabel" ), 6, 1, 0 );
m_used = new QLabel( QString( "%1 %2" ).arg( used, used_dim ), this );
m_layout->addWidget( m_used, 6, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Total:" ), this, "TotalLabel" ), 7, 1, 0 );
m_total = new QLabel( QString( "%1 %2" ).arg( total, total_dim ), this );
m_layout->addWidget( m_total, 7, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Usage:" ), this, "UsageLabel" ), 8, 1, 0 );
m_usage = new QLabel( QString( "%1 %" ).arg( m_item->shareObject()->percentage(), 0, 'f', 1 ), this );
m_layout->addWidget( m_usage, 8, 2, 0 );
}
else
{
QLabel *error = new QLabel( i18n( "This share is inaccessible." ), this );
QFont font;
font.setItalic( true );
error->setFont( font );
m_layout->addMultiCellWidget( error, 5, 5, 1, 2, Qt::AlignCenter );
}
m_pixmap = new QLabel( this );
m_pixmap->setPixmap( m_item->desktopPixmap() );
m_layout->addMultiCellWidget( m_pixmap, 0, m_layout->numRows(), 0, 0, Qt::AlignCenter );
m_is_set_up = true;
}
void Smb4KSharesIconViewToolTip::update()
{
if ( !m_is_set_up )
{
return;
}
// Only change the variable entries:
if ( !m_item->shareObject()->isBroken() )
{
QString total, free, used, total_dim, free_dim, used_dim;
if ( m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( m_item->shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = m_item->shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( m_item->shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( m_item->shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = m_item->shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( m_item->shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
m_free->setText( QString( "%1 %2" ).arg( free, free_dim ) );
m_used->setText( QString( "%1 %2" ).arg( used, used_dim ) );
m_total->setText( QString( "%1 %2" ).arg( total, total_dim ) );
m_usage->setText( QString( "%1 %" ).arg( m_item->shareObject()->percentage(), 0, 'f', 1 ) );
}
else
{
QLabel *free_label = static_cast<QLabel *>( child( "FreeLabel", "QLabel" ) );
if ( free_label )
{
m_layout->remove( free_label );
delete free_label;
}
if ( m_free )
{
m_layout->remove( m_free );
delete m_free;
m_free = NULL;
}
QLabel *used_label = static_cast<QLabel *>( child( "UsedLabel", "QLabel" ) );
if ( used_label )
{
m_layout->remove( used_label );
delete used_label;
}
if ( m_used )
{
m_layout->remove( m_used );
delete m_used;
m_used = NULL;
}
QLabel *total_label = static_cast<QLabel *>( child( "TotalLabel", "QLabel" ) );
if ( total_label )
{
m_layout->remove( total_label );
delete total_label;
}
if ( m_total )
{
m_layout->remove( m_total );
delete m_total;
m_total = NULL;
}
QLabel *usage_label = static_cast<QLabel *>( child( "UsageLabel", "QLabel" ) );
if ( usage_label )
{
m_layout->remove( usage_label );
delete usage_label;
}
if ( m_usage )
{
m_layout->remove( m_usage );
delete m_usage;
m_usage = NULL;
}
QFont font;
font.setItalic( true );
QLabel *error = new QLabel( i18n( "This share is inaccessible." ), this );
error->setFont( font );
error->show();
m_layout->remove( m_pixmap );
m_pixmap->setPixmap( m_item->desktopPixmap() );
m_layout->addMultiCellWidget( error, 5, 5, 1, 2, Qt::AlignCenter );
m_layout->addMultiCellWidget( m_pixmap, 0, 5, 0, 0, Qt::AlignCenter );
}
adjustSize();
}
void Smb4KSharesIconViewToolTip::mousePressEvent( QMouseEvent *e )
{
hide();
QLabel::mousePressEvent( e );
}
void Smb4KSharesIconViewToolTip::leaveEvent( QEvent *e )
{
hide();
QLabel::leaveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesIconViewToolTip::slotHideToolTip()
{
if ( isShown() )
{
hide();
}
}
#include "smb4ksharesiconviewtooltip.moc"

@ -0,0 +1,160 @@
/***************************************************************************
smb4ksharesiconviewtooltip - Tool tip for the shares icon view.
-------------------
begin : Do Jan 4 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESICONVIEWTOOLTIP_H
#define SMB4KSHARESICONVIEWTOOLTIP_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qlabel.h>
#include <qpoint.h>
#include <qlayout.h>
// Forward declarations:
class Smb4KSharesIconViewItem;
/**
* This class provides the tool tip for the shares icon view
* of Smb4K. It shows information about the associated share.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesIconViewToolTip : public QLabel
{
Q_OBJECT
public:
/**
* The constructor.
*
* Please note that the parent of the tool tip will be '0' and
* not the parent widget of @p item. Thus, you have to delete the
* tool tip object in the destructor of the parent widget.
*
* @param item The item for which the tool tip should be shown.
*/
Smb4KSharesIconViewToolTip( Smb4KSharesIconViewItem *item );
/**
* The destructor
*/
~Smb4KSharesIconViewToolTip();
/**
* Show the tool tip. Please note that the tool tip will not be
* shown exactly at position @p pos but with a displacement of 5
* pixels in x- and y-direction.
*
* @param pos The global position of the mouse pointer.
*/
void showTip( const QPoint &pos );
/**
* The shares icon view item for which the tool tip should be shown.
*
* @returns a pointer to a Smb4KSharesIconViewItem object.
*/
Smb4KSharesIconViewItem *item() { return m_item; }
/**
* Update the tool tip by rereading the contents of the shareObject()
* provided by the Smb4KSharesIconViewItem. This function only changes
* those entries that might have changed such as the free and used disk
* space and the usage.
*/
void update();
protected:
/**
* Reimplemented from QLabel.
*/
void mousePressEvent( QMouseEvent *e );
/**
* Reimplemented from QLabel.
*/
void leaveEvent( QEvent *e );
protected slots:
/**
* This slot hides the tool tip after 10 sec.
*/
void slotHideToolTip();
private:
/**
* The item for which the tool tip should be shown
*/
Smb4KSharesIconViewItem *m_item;
/**
* The layout of the tool tip.
*/
QGridLayout *m_layout;
/**
* This function sets up the tool tip.
*/
void setupTip();
/**
* Tells us if the tool tip has already been set up.
*/
bool m_is_set_up;
/**
* This label holds the variable value of the free
* space left on the share.
*/
QLabel *m_free;
/**
* This label holds the variable value of the used
* space on the share.
*/
QLabel *m_used;
/**
* This label holds the value of the total space
* available on the share.
*/
QLabel *m_total;
/**
* This label holds the variable value of the usage
*/
QLabel *m_usage;
/**
* This label holds the pixmap.
*/
QLabel *m_pixmap;
};
#endif

@ -0,0 +1,14 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = libsmb4kshareslistview.la
libsmb4kshareslistview_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(top_builddir)/smb4k/dialogs/libsmb4kdialogs.la $(LIB_KIO) $(LIB_KDECORE) $(LIB_KDEUI) $(KDE_PLUGIN) $(LIB_KPARTS) \
$(LIB_QT)
partrcdir = $(kde_datadir)/smb4kshareslistviewpart
partrc_DATA = smb4kshareslistview_part.rc
libsmb4kshareslistview_la_SOURCES = smb4kshareslistview.cpp \
smb4kshareslistview_part.cpp smb4kshareslistviewitem.cpp smb4kshareslistviewtooltip.cpp
noinst_HEADERS = smb4kshareslistview.h smb4kshareslistview_part.h \
smb4kshareslistviewitem.h smb4kshareslistviewtooltip.h

@ -0,0 +1,275 @@
/***************************************************************************
smb4kshareslistview - This is the shares list view of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qtimer.h>
// KDE includes
#include <klocale.h>
#include <kurl.h>
#include <kio/job.h>
#include <kdeversion.h>
#include <kdebug.h>
// application specific includes
#include "smb4kshareslistview.h"
#include "smb4kshareslistviewitem.h"
#include "smb4kshareslistviewtooltip.h"
#include "../core/smb4ksettings.h"
Smb4KSharesListView::Smb4KSharesListView( QWidget *parent, const char *name )
: KListView( parent, name )
{
setSelectionModeExt( KListView::Single );
setAllColumnsShowFocus( false );
setItemsMovable( false );
setAcceptDrops( true );
// Set up columns
addColumn( i18n( "Item" ) );
addColumn( i18n( "Owner" ) );
#ifndef __FreeBSD__
addColumn( i18n( "Login" ) );
#endif
addColumn( i18n( "File System" ) );
addColumn( i18n( "Free" ) );
addColumn( i18n( "Used" ) );
addColumn( i18n( "Total" ) );
addColumn( i18n( "Usage" ) );
// Set alignment
setColumnAlignment( Free, Qt::AlignRight );
setColumnAlignment( Used, Qt::AlignRight );
setColumnAlignment( Total, Qt::AlignRight );
setColumnAlignment( Usage, Qt::AlignRight );
m_tooltip = NULL;
// Connections:
connect( this, SIGNAL( pressed( QListViewItem * ) ),
this, SLOT( slotPressed( QListViewItem * ) ) );
}
Smb4KSharesListView::~Smb4KSharesListView()
{
if ( m_tooltip )
{
delete m_tooltip;
}
}
void Smb4KSharesListView::updateToolTip()
{
if ( !m_tooltip )
{
return;
}
m_tooltip->update();
}
KURLDrag *Smb4KSharesListView::dragObject()
{
// Get the KURL of the item that is to be dragged:
KURL url = KURL( static_cast<Smb4KSharesListViewItem *>( currentItem() )->shareObject()->canonicalPath() );
KURLDrag *drag = new KURLDrag( KURL::List::List( url ), this );
drag->setPixmap( DesktopIcon( "folder" ) );
// drag->dragCopy();
return drag;
}
void Smb4KSharesListView::startDrag()
{
if ( !Smb4KSettings::enableDragSupport() )
{
return;
}
KListView::startDrag();
}
void Smb4KSharesListView::contentsDragEnterEvent( QDragEnterEvent *e )
{
e->accept( Smb4KSettings::enableDropSupport() );
}
void Smb4KSharesListView::contentsDragMoveEvent( QDragMoveEvent *e )
{
QListViewItem *item = itemAt( contentsToViewport( e->pos() ) );
e->accept( Smb4KSettings::enableDropSupport() && item );
}
void Smb4KSharesListView::contentsDropEvent( QDropEvent *e )
{
QListViewItem *item = itemAt( contentsToViewport( e->pos() ) );
KURL::List src;
// Do we have to stop here?
if ( !Smb4KSettings::enableDropSupport() ||
!item ||
!KURLDrag::decode( e, src ) )
{
e->ignore();
return;
}
KURL dest;
dest.setPath( static_cast<Smb4KSharesListViewItem *>( item )->shareObject()->canonicalPath() );
// Deny dropping if we dropped something on itself.
// This was inspired by KonqOperations::doDrop() function.
for ( KURL::List::Iterator it = src.begin(); it != src.end(); ++it )
{
if ( dest.equals( *it, true ) )
{
if ( e->source() == this || e->source()->parent() == this )
{
e->ignore();
return;
}
}
}
// We only allow copying:
KIO::CopyJob *job = KIO::copy( src, dest, true );
job->setAutoErrorHandlingEnabled( true, NULL );
#if KDE_VERSION_MAJOR >= 3 && KDE_VERSION_MINOR >= 5
job->setAutoWarningHandlingEnabled( true );
#endif
}
void Smb4KSharesListView::contentsMouseMoveEvent( QMouseEvent *e )
{
m_pos = e->globalPos();
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( itemAt( contentsToViewport( e->pos() ) ) );
if ( item )
{
if ( m_tooltip )
{
// Check if tool tip is still valid:
if ( m_tooltip->item() != item )
{
delete m_tooltip;
if ( hasMouse() && Smb4KSettings::showShareToolTip() )
{
m_tooltip = new Smb4KSharesListViewToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
m_tooltip = NULL;
}
}
else
{
// Do nothing
}
}
else
{
// Create new tool tip:
if ( hasMouse() && Smb4KSettings::showShareToolTip() )
{
m_tooltip = new Smb4KSharesListViewToolTip( item );
QTimer::singleShot( 2000, this, SLOT( slotShowToolTip() ) );
}
else
{
// Do nothing
}
}
}
else
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
}
KListView::contentsMouseMoveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesListView::slotPressed( QListViewItem *item )
{
if ( m_tooltip )
{
delete m_tooltip;
m_tooltip = NULL;
}
if ( !item )
{
// Clear the selection if the user clicked onto the
// viewport:
clearSelection();
}
else
{
// Do nothing
}
}
void Smb4KSharesListView::slotShowToolTip()
{
if ( m_tooltip && hasMouse() && Smb4KSettings::showShareToolTip() &&
(m_tooltip->item() == static_cast<Smb4KSharesListViewItem *>( itemAt( viewport()->mapFromGlobal( m_pos ) ) )) )
{
m_tooltip->showTip( m_pos );
}
else
{
delete m_tooltip;
m_tooltip = NULL;
}
}
#include "smb4kshareslistview.moc"

@ -0,0 +1,157 @@
/***************************************************************************
smb4kshareslistview - This is the shares list view of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESLISTVIEW_H
#define SMB4KSHARESLISTVIEW_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <klistview.h>
#include <kurldrag.h>
// forward declarations
class Smb4KSharesListViewToolTip;
/**
* This widget class provides the shares list view of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesListView : public KListView
{
Q_OBJECT
public:
/**
* The constructor
*
* @param parent The parent widget
*
* @param name The name of this object
*/
Smb4KSharesListView( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor
*/
~Smb4KSharesListView();
/**
* Enumeration for the columns.
*/
#ifndef __FreeBSD__
enum Columns { Item = 0,
Owner = 1,
Login = 2,
FileSystem = 3,
Free = 4,
Used = 5,
Total = 6,
Usage = 7 };
#else
enum Columns { Item = 0,
Owner = 1,
FileSystem = 2,
Free = 3,
Used = 4,
Total = 5,
Usage = 6 };
#endif
/**
* Update the tool tip if it exists. This function just executes
* Smb4KSharesListViewToolTip::update().
*/
void updateToolTip();
protected:
/**
* Reimplemented (sort of) from QListView to enable dragging. As QDragObject
* a KURLDrag will be returned.
*
* @returns a KURLDrag object.
*/
KURLDrag *dragObject();
/**
* Reimplemented from QListView to allow some actions to be carried
* out before the drag begins.
*/
void startDrag();
/**
* Reimplemented from QListView.
*/
void contentsDragEnterEvent( QDragEnterEvent * );
/**
* Reimplemented from QListView.
*/
void contentsDragMoveEvent( QDragMoveEvent *e );
/**
* Reimplemented from QListView.
*/
void contentsDropEvent( QDropEvent *e );
/**
* Reimplemented from QListView. This function is used to
* show the tooltips.
*/
void contentsMouseMoveEvent( QMouseEvent *e );
protected slots:
/**
* This slot is connected to KListView::pressed() and clears the selection
* if the user clicked on the viewport.
*
* @param item The QIconViewItem that the user clicked or NULL
* if he/she pressed a mouse button on the viewport.
*/
void slotPressed( QListViewItem *item );
/**
* This slot shows the tool tip for an icon view item.
*/
void slotShowToolTip();
private:
/**
* The current global mouse position
*/
QPoint m_pos;
/**
* The tool tip
*/
Smb4KSharesListViewToolTip *m_tooltip;
};
#endif

@ -0,0 +1,700 @@
/***************************************************************************
smb4kshareslistview_part - This Part includes the shares list view
of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qheader.h>
// KDE includes
#include <kglobal.h>
#include <kstdaction.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kaction.h>
#include <kshortcut.h>
#include <kdebug.h>
#include <kpopupmenu.h>
#include <kiconloader.h>
#include <kactionclasses.h>
// application specific includes
#include "smb4kshareslistview_part.h"
#include "smb4kshareslistview.h"
#include "smb4kshareslistviewitem.h"
#include "../dialogs/smb4ksynchronizationdialog.h"
#include "../core/smb4kshare.h"
#include "../core/smb4kcore.h"
#include "../core/smb4ksettings.h"
KInstance *Smb4KSharesListViewPartFactory::m_instance = 0L;
KAboutData *Smb4KSharesListViewPartFactory::m_about = 0L;
Smb4KSharesListViewPart::Smb4KSharesListViewPart( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name )
: KParts::Part( parent, name )
{
// First of all We need an instance:
setInstance( Smb4KSharesListViewPartFactory::instance() );
// Set the XML file:
setXMLFile( "smb4kshareslistview_part.rc" );
// Set the widget of this part:
m_widget = new Smb4KSharesListView( parentWidget, widgetName );
setWidget( m_widget );
// Set up the actions.
// Do not put this before setWidget() or the shortcuts
// will not be shown.
setupActions();
// Import the shares:
slotMountedShares();
// Load settings:
loadSettings();
// Add some connections:
connect( Smb4KCore::mounter(), SIGNAL( updated() ),
this, SLOT( slotMountedShares() ) );
connect( Smb4KCore::synchronizer(), SIGNAL( state( int ) ),
this, SLOT( slotSynchronizationState( int ) ) );
connect( m_widget, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint & , int) ),
this, SLOT( slotContextMenuRequested( QListViewItem *, const QPoint &, int ) ) );
connect( m_widget, SIGNAL( selectionChanged( QListViewItem * ) ),
this, SLOT( slotSelectionChanged( QListViewItem * ) ) );
connect( m_widget, SIGNAL( pressed( QListViewItem * ) ),
this, SLOT( slotMouseButtonPressed( QListViewItem * ) ) );
connect( m_widget, SIGNAL( executed( QListViewItem * ) ),
this, SLOT( slotFilemanager() ) );
}
Smb4KSharesListViewPart::~Smb4KSharesListViewPart()
{
}
void Smb4KSharesListViewPart::setupActions()
{
// Create the actions:
KAction *unmount = new KAction( i18n( "&Unmount" ), "hdd_unmount", KShortcut( CTRL+Key_U ),
this, SLOT( slotUnmountShare() ),
actionCollection(), "unmount_action" );
#ifdef __linux__
KAction *force = new KAction( i18n( "&Force Unmounting" ), "hdd_unmount", KShortcut( CTRL+Key_F ),
this, SLOT( slotForceUnmountShare() ),
actionCollection(), "force_unmount_action" );
#endif
KAction *all = new KAction( i18n( "U&nmount All" ), "gear", KShortcut( CTRL+Key_N ),
this, SLOT( slotUnmountAllShares() ),
actionCollection(), "unmount_all_action" );
KAction *sync = new KAction( i18n( "S&ynchronize" ), "bottom", KShortcut( CTRL+Key_Y ),
this, SLOT( slotSynchronize() ),
actionCollection(), "synchronize_action" );
KAction *konsole = new KAction( i18n( "Open with Konso&le" ), "terminal", KShortcut( CTRL+Key_L ),
this, SLOT( slotKonsole() ),
actionCollection(), "konsole_action" );
KAction *konq = new KAction( i18n( "Open with &Konqueror" ), "kfm_home", KShortcut( CTRL+Key_K ),
this, SLOT( slotFilemanager() ),
actionCollection(), "filemanager_action" );
// Disable all actions for now:
unmount->setEnabled( false );
#ifdef __linux__
force->setEnabled( false );
#endif
all->setEnabled( false );
sync->setEnabled( false );
konsole->setEnabled( false );
konq->setEnabled( false );
// Insert the actions into the menu:
m_menu = new KActionMenu( this, "SharesListViewMenu" );
m_menu->popupMenu()->insertTitle( SmallIcon( "hdd_mount" ), i18n( "Shares" ), 0 );
m_menu->insert( unmount, -1 );
#ifdef __linux__
m_menu->insert( force, -1 );
#endif
m_menu->insert( all, -1 );
m_menu->popupMenu()->insertSeparator( -1 );
m_menu->insert( sync, -1 );
m_menu->popupMenu()->insertSeparator( -1 );
m_menu->insert( konsole, -1 );
m_menu->insert( konq, -1 );
}
void Smb4KSharesListViewPart::loadSettings()
{
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() );
#endif
m_widget->setColumnWidth( Smb4KSharesListView::Item, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Item, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Item );
if ( Smb4KSettings::showOwner() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Owner, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Owner, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Owner );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Owner, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Owner, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Owner );
}
#ifndef __FreeBSD__
if ( Smb4KSettings::showLogin() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Login, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Login, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Login );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Login, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Login, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Login );
}
#endif
if ( Smb4KSettings::showFileSystem() )
{
m_widget->setColumnWidth( Smb4KSharesListView::FileSystem, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::FileSystem, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::FileSystem );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::FileSystem, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::FileSystem, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::FileSystem );
}
if ( Smb4KSettings::showFreeDiskSpace() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Free, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Free, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Free );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Free, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Free, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Free );
}
if ( Smb4KSettings::showUsedDiskSpace() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Used, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Used, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Used );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Used, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Used, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Used );
}
if ( Smb4KSettings::showTotalDiskSpace() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Total, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Total, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Total );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Total, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Total, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Total );
}
if ( Smb4KSettings::showDiskUsage() )
{
m_widget->setColumnWidth( Smb4KSharesListView::Usage, 10 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Usage, QListView::Maximum );
m_widget->header()->setResizeEnabled( true, Smb4KSharesListView::Usage );
}
else
{
m_widget->setColumnWidth( Smb4KSharesListView::Usage, 0 );
m_widget->setColumnWidthMode( Smb4KSharesListView::Usage, QListView::Manual );
m_widget->header()->setResizeEnabled( false, Smb4KSharesListView::Usage );
}
// Change the text of the share (first column):
QListViewItemIterator it( m_widget );
Smb4KSharesListViewItem *item = NULL;
while( it.current() )
{
item = static_cast<Smb4KSharesListViewItem *>( it.current() );
if ( item )
{
item->setText( 0, (Smb4KSettings::showMountPoint() ?
item->shareObject()->path() :
item->shareObject()->name()) );
}
++it;
}
// Enable/disable support for dropping:
m_widget->setAcceptDrops( Smb4KSettings::enableDropSupport() );
// Load or remove all foreign shares. The easiest way to do this
// is to invoke slotMountedShares():
slotMountedShares();
// Adjust the columns:
for ( int col = 0; col < m_widget->columns(); col++ )
{
if ( m_widget->columnWidth( col ) != 0 )
{
m_widget->adjustColumn( col );
}
}
}
void Smb4KSharesListViewPart::customEvent( QCustomEvent *e )
{
switch ( e->type() )
{
case EVENT_LOAD_SETTINGS:
{
loadSettings();
slotMountedShares();
break;
}
case EVENT_SET_FOCUS:
{
KListView *view = static_cast<KListView *>( m_widget );
if ( view->childCount() != 0 )
{
view->setSelected( !view->currentItem() ?
view->firstChild() :
view->currentItem(), true );
}
view->setFocus();
break;
}
default:
{
break;
}
}
KParts::Part::customEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS (Smb4KSharesListViewPart)
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesListViewPart::slotContextMenuRequested( QListViewItem *item, const QPoint &pos, int /*col*/ )
{
if ( item )
{
m_menu->popupMenu()->changeTitle( 0, SmallIcon( "hdd_mount" ),
static_cast<Smb4KSharesListViewItem *>( item )->shareObject()->name() );
}
else
{
m_menu->popupMenu()->changeTitle( 0, SmallIcon( "hdd_mount" ), i18n( "Shares" ) );
}
m_menu->popupMenu()->exec( pos, 0 );
}
void Smb4KSharesListViewPart::slotSelectionChanged( QListViewItem *item )
{
// NOTE: Here we only enable or disable the KActions. All other things
// are done in the Smb4KSharesListView class.
// This slot is used to enable or disable the actions when the user
// changes the item in the list view. This slot won't be called when
// the user clicks on the view port!
if ( item )
{
actionCollection()->action( "unmount_action" )->setEnabled( true );
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( Smb4KSettings::useForceUnmount() );
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( true );
Smb4KShare *share = static_cast<Smb4KSharesListViewItem *>( item )->shareObject();
if ( !share->isBroken() )
{
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() );
actionCollection()->action( "filemanager_action" )->setEnabled( true );
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
!Smb4KCore::synchronizer()->isRunning() );
}
else
{
actionCollection()->action( "konsole_action" )->setEnabled( false );
actionCollection()->action( "filemanager_action" )->setEnabled( false );
actionCollection()->action( "synchronize_action" )->setEnabled( false );
}
}
else
{
// Smb4KSharesListViewPart::slotMouseButtonPressed()
}
}
void Smb4KSharesListViewPart::slotMouseButtonPressed( QListViewItem *item )
{
// NOTE: Here we only enable or disable the KActions. All other things
// are done in the Smb4KSharesListView class.
// Here we do all the stuff that cannot be done in
// Smb4KSharesListViewPart::slotSelectionChanged()
if ( !item )
{
actionCollection()->action( "unmount_action" )->setEnabled( false );
#ifdef __linux__
actionCollection()->action( "force_unmount_action" )->setEnabled( false );
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( (m_widget->childCount() > 0) );
actionCollection()->action( "konsole_action" )->setEnabled( false );
actionCollection()->action( "filemanager_action" )->setEnabled( false );
actionCollection()->action( "synchronize_action" )->setEnabled( false );
}
else
{
// See Smb4KSharesListViewPart::slotSelectionChanged()
}
}
void Smb4KSharesListViewPart::slotMountedShares()
{
// Get the list of shares:
QValueList<Smb4KShare *> list = Smb4KCore::mounter()->getShares();
// Update the view:
if ( !list.isEmpty() )
{
// Remove all obsolete items:
QListViewItemIterator it( m_widget );
Smb4KSharesListViewItem *item = NULL;
while ( it.current() )
{
item = static_cast<Smb4KSharesListViewItem *>( it.current() );
Smb4KShare *share = Smb4KCore::mounter()->findShareByPath( item->shareObject()->path() );
if( !share || (item->shareObject()->isForeign() && !Smb4KSettings::showAllShares()) )
{
delete item;
item = NULL;
}
++it;
}
// Now process the entries in the list:
bool already_in_view = false;
for ( QValueListConstIterator<Smb4KShare *> it = list.begin(); it != list.end(); ++it )
{
// Check, whether the share is already in the list. Look for the
// mount point.
for ( Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->firstChild() );
item; item = static_cast<Smb4KSharesListViewItem *>( item->nextSibling() ) )
{
if ( QString::compare( item->shareObject()->path(), (*it)->path() ) == 0 ||
QString::compare( item->shareObject()->canonicalPath(), (*it)->canonicalPath() ) == 0 )
{
// Replace the share object if something changed:
if ( !item->sameShareObject( *it ) )
{
item->replaceShareObject( *it );
}
already_in_view = true;
break;
}
else
{
continue;
}
}
if ( !already_in_view )
{
if ( !Smb4KSettings::showAllShares() && (*it)->isForeign() )
{
// If the user does not want to have foreign shares
// displayed continue.
continue;
}
else
{
// Put the new item into the list view:
(void) new Smb4KSharesListViewItem( *it, Smb4KSettings::showMountPoint(), m_widget );
// Adjust the columns:
for ( int col = 0; col < m_widget->columns(); col++ )
{
if ( m_widget->columnWidth( col ) != 0 )
{
m_widget->adjustColumn( col );
}
}
continue;
}
}
already_in_view = false;
}
m_widget->sort();
}
else
{
if ( m_widget->childCount() != 0 )
{
m_widget->clear();
// Adjust the columns:
for ( int col = 0; col < m_widget->columns(); col++ )
{
if ( m_widget->columnWidth( col ) != 0 )
{
m_widget->adjustColumn( col );
}
}
}
}
// Update the tool tip, if it exists:
if ( m_widget->childCount() != 0 )
{
m_widget->updateToolTip();
}
// Enable/disable the actions:
QListViewItem *item = m_widget->currentItem();
bool have_selected_item = (item && item->isSelected());
actionCollection()->action( "unmount_action" )->setEnabled( have_selected_item );
#ifdef __linux__
if ( Smb4KSettings::useForceUnmount() )
{
actionCollection()->action( "force_unmount_action" )->setEnabled( have_selected_item );
}
else
{
actionCollection()->action( "force_unmount_action" )->setEnabled( false );
}
#endif
actionCollection()->action( "unmount_all_action" )->setEnabled( (m_widget->childCount() > 0) );
actionCollection()->action( "konsole_action" )->setEnabled( !Smb4KSettings::konsole().isEmpty() && have_selected_item );
actionCollection()->action( "filemanager_action" )->setEnabled( have_selected_item );
actionCollection()->action( "synchronize_action" )->setEnabled( !Smb4KSettings::rsync().isEmpty() &&
!Smb4KCore::synchronizer()->isRunning() &&
have_selected_item );
}
void Smb4KSharesListViewPart::slotUnmountShare()
{
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->currentItem() );
if ( item )
{
Smb4KCore::mounter()->unmountShare( item->shareObject(), false );
}
}
void Smb4KSharesListViewPart::slotForceUnmountShare()
{
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->currentItem() );
if ( item )
{
Smb4KCore::mounter()->unmountShare( item->shareObject(), true );
}
}
void Smb4KSharesListViewPart::slotUnmountAllShares()
{
Smb4KCore::mounter()->unmountAllShares();
}
void Smb4KSharesListViewPart::slotSynchronize()
{
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->currentItem() );
Smb4KSynchronizationDialog *dlg = static_cast<Smb4KSynchronizationDialog *>( m_widget->child( "SynchronizationDialog", "Smb4KSynchronizationDialog", true ) );
if ( item && !item->shareObject()->isBroken() && !dlg )
{
dlg = new Smb4KSynchronizationDialog( item->shareObject(), m_widget, "SynchronizationDialog" );
dlg->show();
}
}
void Smb4KSharesListViewPart::slotKonsole()
{
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->currentItem() );
if ( item && !item->shareObject()->isBroken() )
{
Smb4KCore::open( item->shareObject(), Smb4KCore::Konsole );
}
}
void Smb4KSharesListViewPart::slotFilemanager()
{
Smb4KSharesListViewItem *item = static_cast<Smb4KSharesListViewItem *>( m_widget->currentItem() );
if ( item && !item->shareObject()->isBroken() )
{
Smb4KCore::open( item->shareObject(), Smb4KCore::Konqueror );
}
}
void Smb4KSharesListViewPart::slotSynchronizationState( int state )
{
switch ( state )
{
case SYNCHRONIZER_START:
{
actionCollection()->action( "synchronize_action" )->setEnabled( false );
break;
}
case SYNCHRONIZER_STOP:
{
actionCollection()->action( "synchronize_action" )->setEnabled( true );
break;
}
default:
{
break;
}
}
}
/////////////////////////////////////////////////////////////////////////////
// FACTORY STUFF
/////////////////////////////////////////////////////////////////////////////
Smb4KSharesListViewPartFactory::Smb4KSharesListViewPartFactory()
: KParts::Factory()
{
}
Smb4KSharesListViewPartFactory::~Smb4KSharesListViewPartFactory()
{
delete m_instance;
delete m_about;
m_instance = 0L;
}
KParts::Part *Smb4KSharesListViewPartFactory::createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name, const char *, const QStringList & )
{
Smb4KSharesListViewPart *obj = new Smb4KSharesListViewPart( parentWidget, widgetName, parent, name );
// See if we are to be read-write or not
// if (QCString(classname) == "KParts::ReadOnlyPart")
// {
// obj->setReadWrite(false);
// }
return obj;
}
KInstance *Smb4KSharesListViewPartFactory::instance()
{
if( !m_instance )
{
m_about = new KAboutData( "smb4kshareslistviewpart", I18N_NOOP( "Smb4KSharesListViewPart" ), "1.0" );
m_about->addAuthor("Alexander Reinholdt", 0, "dustpuppy@users.berlios.de");
m_about->setLicense( KAboutData::License_GPL );
m_instance = new KInstance( m_about );
}
return m_instance;
}
/////////////////////////////////////////////////////////////////////////////
// INIT
/////////////////////////////////////////////////////////////////////////////
extern "C"
{
void *init_libsmb4kshareslistview()
{
KGlobal::locale()->insertCatalogue( "smb4k" );
return new Smb4KSharesListViewPartFactory;
}
}
#include "smb4kshareslistview_part.moc"

@ -0,0 +1,234 @@
/***************************************************************************
smb4kshareslistview_part -This Part includes the shares list view
of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESLISTVIEW_PART_H
#define SMB4KSHARESLISTVIEW_PART_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kparts/part.h>
#include <kparts/factory.h>
// applications specific includes
#include "smb4kshareslistview.h"
/**
* This is one of the parts of Smb4K. It contains the shares list
* view.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesListViewPart : public KParts::Part
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parentWidget The parent widget
*
* @param widgetName The name the widget should have
*
* @param parent The parent object
*
* @param name The name this object should have
*/
Smb4KSharesListViewPart( QWidget *parentWidget = 0, const char *widgetName = 0,
QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
virtual ~Smb4KSharesListViewPart();
protected:
/**
* Reimplemented from KParts::Part.
*/
void customEvent( QCustomEvent *e );
protected slots:
/**
* Opens a context menu over the list view item @p item at position
* @p pos if requested.
*
* @param item The list view item or NULL if the user clicked
* somewhere else.
*
* @param pos The position where the user clicked.
*
* @param col The column where the context menu should be show.
*/
void slotContextMenuRequested( QListViewItem *item, const QPoint & pos, int col );
/**
* This slot is called when the selection in the list view changed. It
* enables or disables the actions according to known options/states.
* Please note that it won't be invoked when the user clicked on the
* viewport. Use slotMouseButtonPressed() to also catch that event.
*
* @param item The list view item that was selected
*/
void slotSelectionChanged( QListViewItem *item );
/**
* This slot is called when the user presses any mouse button somewhere
* in the list view. It enables or disables the actions according to known
* options/states.
*
* @param item The icon view item that was clicked or NULL if the
* user clicked onto the viewport.
*/
void slotMouseButtonPressed( QListViewItem *item );
/**
* This slot is called by the Smb4KMounter::updated() signal and updates
* the list view according to the list that is returned by Smb4KMounter::getShares().
*/
void slotMountedShares();
/**
* This slot is connected to the 'Unmount action'. You will be able to
* unmount a certain share when activating this slot.
*/
void slotUnmountShare();
/**
* This slot is connected to the 'Force Unmounting' action and is, thus,
* only useful under Linux, because only there the possibility for a forced
* (i.e. lazy) unmount exists.
*
* When activating this slot, the selected share will be unmounted, even if
* it is not accessible or the server already went offline.
*/
void slotForceUnmountShare();
/**
* This slot is connected to the 'Unmount All' action. All shares - either of
* the user or that are present on the system (depending on the settings the
* user chose) - will be unmounted. Please note that Smb4KMounter::unmountAllShares()
* is invoked directly.
*/
void slotUnmountAllShares();
/**
* This slot is connected to the 'Synchronize' action. The current item will be
* synchronized with a local copy (or vice versa) if you activate it.
*/
void slotSynchronize();
/**
* This slot is connected to the 'Konsole' action. The mount point of the current
* share item will be opened in Konsole.
*/
void slotKonsole();
/**
* This slot is connected to the 'Konqueror' action. The contents of the current
* share item will be opened in the file manager.
*/
void slotFilemanager();
/**
* This slot is called by the synchronizer whenever the state of the synchronization
* process changed.
*
* @param state The state the synchronizer is in.
*/
void slotSynchronizationState( int state );
private:
/**
* Set up the actions
*/
void setupActions();
/**
* Load settings for the widget or the actions.
*/
void loadSettings();
/**
* The icon view.
*/
Smb4KSharesListView *m_widget;
/**
* The action menu.
*/
KActionMenu *m_menu;
};
class KInstance;
class KAboutData;
class Smb4KSharesListViewPartFactory : public KParts::Factory
{
Q_OBJECT
public:
/**
* The constructor
*/
Smb4KSharesListViewPartFactory();
/**
* The destructor
*/
virtual ~Smb4KSharesListViewPartFactory();
/**
* Reimplemented from KParts::Factory
*/
virtual KParts::Part *createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const char *classname, const QStringList &args );
/**
* The instance
*/
static KInstance *instance();
private:
/**
* The factory's instance.
*/
static KInstance *m_instance;
/**
* The factory's KAboutData object
*/
static KAboutData *m_about;
};
#endif

@ -0,0 +1,25 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="smb4kshareslistview_part" version="1">
<MenuBar>
<Menu name="shares"><text>&amp;Shares</text>
<Action name="unmount_action"/>
<Action name="force_unmount_action"/>
<Action name="unmount_all_action"/>
<Separator/>
<Action name="synchronize_action"/>
<Separator/>
<Action name="konsole_action"/>
<Action name="filemanager_action"/>
</Menu>
</MenuBar>
<ToolBar name="sharesViewToolBar">
<Action name="unmount_action"/>
<Action name="force_unmount_action"/>
<Action name="unmount_all_action"/>
<Separator/>
<Action name="synchronize_action"/>
<Separator/>
<Action name="konsole_action"/>
<Action name="filemanager_action"/>
</ToolBar>
</kpartgui>

@ -0,0 +1,353 @@
/***************************************************************************
smb4kshareslistviewitem - The shares list view item class of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qpixmap.h>
#include <qcolor.h>
// KDE includes
#include <kiconeffect.h>
#include <kdebug.h>
// application specific includes
#include "smb4kshareslistviewitem.h"
#include "smb4kshareslistview.h"
Smb4KSharesListViewItem::Smb4KSharesListViewItem( Smb4KShare *share, bool mountpoint,
Smb4KSharesListView *parent )
: KListViewItem( parent ), m_share( *share ), m_mountpoint( mountpoint ),
m_initial_setup( true )
{
setDropEnabled( true );
setDragEnabled( true );
m_loader = new KIconLoader();
setupItem( m_share, m_mountpoint );
}
Smb4KSharesListViewItem::~Smb4KSharesListViewItem()
{
// Do not touch the Smb4KShare object!
delete m_loader;
}
void Smb4KSharesListViewItem::setupItem( const Smb4KShare &share, bool mountpoint )
{
// Only do something here if either the item hasn't been set up
// yet, or share and mountpoint changed, respectively.
if ( m_initial_setup || !m_share.equals( share ) || m_mountpoint != mountpoint )
{
if ( m_initial_setup || m_share.isBroken() != share.isBroken() )
{
QPixmap pix;
int icon_state = m_share.isForeign() ? KIcon::DisabledState : KIcon::DefaultState;
if ( m_share.isBroken() )
{
QImage over = m_loader->loadIcon( "button_cancel", KIcon::Small,
0, icon_state, 0L, false ).convertToImage();
QImage src = m_loader->loadIcon( "hdd_mount", KIcon::Small,
0, icon_state, 0L, false ).convertToImage();
QImage over_desk = m_loader->loadIcon( "button_cancel", KIcon::Desktop,
0, icon_state, 0L, false ).convertToImage();
QImage src_desk = m_loader->loadIcon( "hdd_mount", KIcon::Desktop,
0, icon_state, 0L, false ).convertToImage();
KIconEffect e;
e.semiTransparent( over );
e.overlay( src, over );
e.semiTransparent( over_desk );
e.overlay( src_desk, over_desk );
pix = QPixmap( src );
m_desktop_pixmap = QPixmap( src_desk );
}
else
{
pix = m_loader->loadIcon( "hdd_mount", KIcon::Small,
0, icon_state, 0L, false );
m_desktop_pixmap = m_loader->loadIcon( "hdd_mount", KIcon::Desktop,
0, icon_state, 0L, false );
}
setPixmap( Item, pix );
}
else
{
// Do nothing
}
if ( !m_initial_setup )
{
if ( m_mountpoint != mountpoint )
{
setText( Item, (m_mountpoint ? m_share.path() : m_share.name()) );
}
// The file system, owner and login won't change
QString total, free, used, total_dim, free_dim, used_dim;
if ( shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
setText( Free, QString( "%1 %2" ).arg( free, free_dim ) );
setText( Used, QString( "%1 %2" ).arg( used, used_dim ) );
setText( Total, QString( "%1 %2" ).arg( total, total_dim ) );
}
else
{
setText( Item, (m_mountpoint ? m_share.path() : m_share.name()) );
setText( Owner, QString::compare( m_share.filesystem(), "smbfs" ) == 0 ?
QString( "%1 - %2" ).arg( m_share.user() ).arg( m_share.group() ) :
QString::null );
#ifndef __FreeBSD__
setText( Login, QString::compare( m_share.filesystem(), "cifs" ) == 0 ?
m_share.cifsLogin() :
QString::null );
#endif
setText( FileSystem, m_share.filesystem().upper() );
QString total, free, used, total_dim, free_dim, used_dim;
if ( shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = shareObject()->totalDiskSpace() - shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
setText( Free, QString( "%1 %2" ).arg( free, free_dim ) );
setText( Used, QString( "%1 %2" ).arg( used, used_dim ) );
setText( Total, QString( "%1 %2" ).arg( total, total_dim ) );
}
m_initial_setup = false;
m_share = share;
m_mountpoint = mountpoint;
}
else
{
// Do nothing
}
}
bool Smb4KSharesListViewItem::sameShareObject( Smb4KShare *share )
{
return m_share.equals( *share );
}
void Smb4KSharesListViewItem::replaceShareObject( Smb4KShare *share )
{
setupItem( *share, m_mountpoint );
}
void Smb4KSharesListViewItem::paintCell( QPainter *p, const QColorGroup &cg, int col, int width, int align )
{
// Set the color of the item text:
QColorGroup colorgrp( cg );
if ( m_share.isForeign() )
{
colorgrp.setColor( QColorGroup::Text, Qt::gray );
}
if ( col != Usage )
{
KListViewItem::paintCell( p, colorgrp, col, width, align );
return;
}
// Draw the usage:
// This code was inspired by KAudioCreator.
p->setPen( colorgrp.base() );
p->drawRect( 0, 0, width, height() );
if ( isSelected() )
{
p->fillRect( 1, 1, width-2, height()-2, colorgrp.highlight() );
}
else
{
p->fillRect( 1, 1, width-2, height()-2, colorgrp.base() );
}
if ( !m_share.isBroken() )
{
int percent = (int)(((double)(width-2)) * (m_share.percentage()/100));
p->fillRect( 1, 1, percent, height()-2, !m_share.isForeign() ? Qt::red : Qt::red.light( 175 ) );
p->fillRect( percent+1, 1, width-percent-2, height()-2, !m_share.isForeign() ? Qt::green : Qt::green.light( 175 ) );
p->setPen( !m_share.isForeign() ? colorgrp.foreground() : Qt::gray );
p->drawRect( 1, 1, width-2, height()-2 );
// Show the text:
p->setPen( colorgrp.text() );
// if ( isSelected() )
// {
// p->setPen( colorgrp.highlightedText() );
// }
p->drawText( 0, 0, width-1, height()-1, Qt::AlignCenter, QString( "%1 \%" ).arg( m_share.percentage(), 0, 'f', 1 ) );
}
else
{
p->fillRect( 1, 1, width-2, height()-2, colorgrp.base() );
p->setPen( !m_share.isForeign() ? colorgrp.foreground() : Qt::gray );
p->drawRect( 1, 1, width-2, height()-2 );
}
}
bool Smb4KSharesListViewItem::acceptDrop( const QMimeSource *source ) const
{
if ( source->provides( "text/plain" ) )
{
return true;
}
return false;
}

@ -0,0 +1,203 @@
/***************************************************************************
smb4kshareslistviewitem - The shares list view item class of Smb4K.
-------------------
begin : Sa Jun 30 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESLISTVIEWITEM_H
#define SMB4KSHARESLISTVIEWITEM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qpainter.h>
#include <qpalette.h>
// KDE includes
#include <klistview.h>
#include <kiconloader.h>
// application specific includes
#include "../core/smb4kshare.h"
// forward declarations
class Smb4KSharesListView;
/**
* This class provides the items for the shares icon view
* of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesListViewItem : public KListViewItem
{
public:
/**
* The constructor.
*
* @param share The Smb4KShare object that represents the share.
*
* @param mountpoint Tells the item if the mount point instead of the
* share name should be shown. Default is FALSE.
*
* @param parent The parent widget of this item.
*/
Smb4KSharesListViewItem( Smb4KShare *share,
bool mountpoint = false,
Smb4KSharesListView *parent = 0 );
/**
* The destructor
*/
~Smb4KSharesListViewItem();
/**
* This function compares the encapsulated Smb4KShare object with @p item
* and returns TRUE if they contain equal values.
*
* @param item A Smb4KShare object that should be compared
*
* @returns TRUE if @p item has the same values stored as the
* encapsulated Smb4KShare object.
*/
bool sameShareObject( Smb4KShare *share );
/**
* Replace the encapsulated Smb4KShare object. This function just passes
* the share object to setupItem() which does all the work.
*
* @param share The new Smb4KShare object
*/
void replaceShareObject( Smb4KShare *share );
/**
* Returns a pointer to the share object that's represented by this item.
* You have to use it to access its data.
*
* @returns a pointer to a Smb4KShare object.
*/
Smb4KShare *shareObject() { return &m_share; }
/**
* Enumeration for the columns.
*/
#ifndef __FreeBSD__
enum Columns { Item = 0,
Owner = 1,
Login = 2,
FileSystem = 3,
Free = 4,
Used = 5,
Total = 6,
Usage = 7 };
#else
enum Columns { Item = 0,
Owner = 1,
FileSystem = 2,
Free = 3,
Used = 4,
Total = 5,
Usage = 6 };
#endif
/**
* This function returns the desktop pixmap of this item.
*
* @returns the destop pixmap of this item.
*/
const QPixmap &desktopPixmap() { return m_desktop_pixmap; }
protected:
/**
* Reimplemented from KListViewItem.
*
* This function paints the icon text and the usage. It uses Smb4KShare::isForeign() to
* determine the color of the icon text (TRUE: gray, FALSE: the default color).
*
* @param p The painter
*
* @param cg The color group
*
* @param column The column of the list view
*
* @param width The width of the area that will be painted.
*
* @param alignment The alignment of the column that will be used.
*/
void paintCell( QPainter *p,
const QColorGroup &cg,
int column,
int width,
int alignment );
/**
* Reimplemented from KListViewItem.
*
* This function accepts or denies drops according to the contents of @p source.
*
* @param source The mime source
*/
bool acceptDrop( const QMimeSource *source ) const;
private:
/**
* Set up the icon and text of the item with respect to @p share and @p mountpoint.
*
* @param share The Smb4KShare object.
*
* @param mountpoint If TRUE, the mount point will be shown instead of the
* share name.
*/
void setupItem( const Smb4KShare &share,
bool mountpoint = false );
/**
* The Smb4KShare object representing the share.
*/
Smb4KShare m_share;
/**
* Tells us if the mount point instead of the share
* name should be shown.
*/
bool m_mountpoint;
/**
* Tells us that the initial setup already happened.
*/
bool m_initial_setup;
/**
* The icon loader for this item.
*/
KIconLoader *m_loader;
/**
* The desktop pixmap
*/
QPixmap m_desktop_pixmap;
};
#endif

@ -0,0 +1,429 @@
/***************************************************************************
smb4kshareslistviewtooltip - Tool tip for the shares list view.
-------------------
begin : So Jul 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qtooltip.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qtimer.h>
// KDE includes
#include <klocale.h>
#include <kdebug.h>
// application specific includes
#include "smb4kshareslistviewtooltip.h"
#include "smb4kshareslistviewitem.h"
Smb4KSharesListViewToolTip::Smb4KSharesListViewToolTip( Smb4KSharesListViewItem *item )
: QLabel( 0, "SharesListViewToolTip", WStyle_StaysOnTop | WStyle_Customize |
WStyle_NoBorder | WStyle_Tool | WX11BypassWM | WDestructiveClose ), m_item( item )
{
setPalette( QToolTip::palette() );
setLineWidth( 1 );
setMidLineWidth( 1 );
setFrameShape( Box );
setFrameShadow( Plain );
setMouseTracking( true );
m_layout = new QGridLayout( this );
m_layout->setMargin( 10 );
m_layout->setSpacing( 3 );
m_is_set_up = false;
m_free = NULL;
m_used = NULL;
m_total = NULL;
m_usage = NULL;
m_pixmap = NULL;
// We will set up the tip in the showTip() function.
}
Smb4KSharesListViewToolTip::~Smb4KSharesListViewToolTip()
{
// Never touch the Smb4KSharesListViewItem object here!
}
void Smb4KSharesListViewToolTip::showTip( const QPoint &pos )
{
if ( !m_item || isShown() )
{
return;
}
setupTip();
adjustSize();
QDesktopWidget *d = QApplication::desktop();
QPoint p( pos );
if ( p.x() + width() > d->width() )
{
p.setX( p.x() - width() - 5 );
}
else
{
p.setX( p.x() + 5 );
}
if ( p.y() + height() > d->height() )
{
p.setY( p.y() - height() - 5 );
}
else
{
p.setY( p.y() + 5 );
}
setGeometry( p.x(), p.y(), width(), height() );
polish();
show();
QTimer::singleShot( 10000, this, SLOT( slotHideToolTip() ) );
}
void Smb4KSharesListViewToolTip::setupTip()
{
if ( !m_item )
{
return;
}
m_layout->addWidget( new QLabel( i18n( "Share:" ), this ), 0, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->name(), this ), 0, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Mount point:" ), this ), 1, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->path(), this ), 1, 2, 0 );
if ( QString::compare( m_item->shareObject()->filesystem(), "smbfs" ) == 0 )
{
m_layout->addWidget( new QLabel( "Owner:", this ), 2, 1, 0 );
m_layout->addWidget( new QLabel( QString( "%1 - %2" ).arg( m_item->shareObject()->user(), m_item->shareObject()->group() ), this ), 2, 2, 0 );
}
else
{
m_layout->addWidget( new QLabel( "Login:", this ), 2, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->cifsLogin(), this ), 2, 2, 0 );
}
m_layout->addWidget( new QLabel( i18n( "File system:" ), this ), 3, 1, 0 );
m_layout->addWidget( new QLabel( m_item->shareObject()->filesystem().upper(), this ), 3, 2, 0 );
QFrame *line = new QFrame( this );
line->setLineWidth( 1 );
line->setMidLineWidth( 0 );
line->setFixedWidth( 100 );
line->setFrameShape( QFrame::HLine );
line->setFrameShadow( QFrame::Plain );
m_layout->addMultiCellWidget( line, 4, 4, 1, 2, Qt::AlignCenter );
// Prepare the disk usage stuff.
if ( !m_item->shareObject()->isBroken() )
{
QString total, free, used, total_dim, free_dim, used_dim;
if ( m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( m_item->shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = m_item->shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( m_item->shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( m_item->shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = m_item->shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( m_item->shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
m_layout->addWidget( new QLabel( i18n( "Free:" ), this, "FreeLabel" ), 5, 1, 0 );
m_free = new QLabel( QString( "%1 %2" ).arg( free, free_dim ), this );
m_layout->addWidget( m_free, 5, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Used:" ), this, "UsedLabel" ), 6, 1, 0 );
m_used = new QLabel( QString( "%1 %2" ).arg( used, used_dim ), this );
m_layout->addWidget( m_used, 6, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Total:" ), this, "TotalLabel" ), 7, 1, 0 );
m_total = new QLabel( QString( "%1 %2" ).arg( total, total_dim ), this );
m_layout->addWidget( m_total, 7, 2, 0 );
m_layout->addWidget( new QLabel( i18n( "Usage:" ), this, "UsageLabel" ), 8, 1, 0 );
m_usage = new QLabel( QString( "%1 %" ).arg( m_item->shareObject()->percentage(), 0, 'f', 1 ), this );
m_layout->addWidget( m_usage, 8, 2, 0 );
}
else
{
QLabel *error = new QLabel( i18n( "This share is inaccessible." ), this );
QFont font;
font.setItalic( true );
error->setFont( font );
m_layout->addMultiCellWidget( error, 5, 5, 1, 2, Qt::AlignCenter );
}
m_pixmap = new QLabel( this );
m_pixmap->setPixmap( m_item->desktopPixmap() );
m_layout->addMultiCellWidget( m_pixmap, 0, m_layout->numRows(), 0, 0, Qt::AlignCenter );
m_is_set_up = true;
}
void Smb4KSharesListViewToolTip::update()
{
if ( !m_is_set_up )
{
return;
}
// Only change the variable entries:
if ( !m_item->shareObject()->isBroken() )
{
QString total, free, used, total_dim, free_dim, used_dim;
if ( m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace() > 1024 )
{
double tmp_used = (m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace()) / 1024;
used_dim = "MB";
if ( tmp_used >= 1024 )
{
tmp_used = tmp_used / 1024;
used_dim = "GB";
}
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
else
{
used_dim = "kB";
double tmp_used = m_item->shareObject()->totalDiskSpace() - m_item->shareObject()->freeDiskSpace();
used = QString( "%1" ).arg( tmp_used, 0, 'f', 1 );
}
if ( m_item->shareObject()->freeDiskSpace() >= 1024 )
{
double tmp_free = m_item->shareObject()->freeDiskSpace() / 1024;
free_dim = "MB";
if ( tmp_free >= 1024 )
{
tmp_free = tmp_free / 1024;
free_dim = "GB";
}
free = QString( "%1" ).arg( tmp_free, 0, 'f', 1 );
}
else
{
free_dim = "kB";
free = QString( "%1" ).arg( m_item->shareObject()->freeDiskSpace(), 0, 'f', 1 );
}
if ( m_item->shareObject()->totalDiskSpace() >= 1024 )
{
double tmp_total = m_item->shareObject()->totalDiskSpace() / 1024;
total_dim = "MB";
if ( tmp_total >= 1024 )
{
tmp_total = tmp_total / 1024;
total_dim = "GB";
}
total = QString( "%1" ).arg( tmp_total, 0, 'f', 1 );
}
else
{
total_dim = "kB";
total = QString( "%1" ).arg( m_item->shareObject()->totalDiskSpace(), 0, 'f', 1 );
}
m_free->setText( QString( "%1 %2" ).arg( free, free_dim ) );
m_used->setText( QString( "%1 %2" ).arg( used, used_dim ) );
m_total->setText( QString( "%1 %2" ).arg( total, total_dim ) );
m_usage->setText( QString( "%1 %" ).arg( m_item->shareObject()->percentage(), 0, 'f', 1 ) );
}
else
{
QLabel *free_label = static_cast<QLabel *>( child( "FreeLabel", "QLabel" ) );
if ( free_label )
{
m_layout->remove( free_label );
delete free_label;
}
if ( m_free )
{
m_layout->remove( m_free );
delete m_free;
m_free = NULL;
}
QLabel *used_label = static_cast<QLabel *>( child( "UsedLabel", "QLabel" ) );
if ( used_label )
{
m_layout->remove( used_label );
delete used_label;
}
if ( m_used )
{
m_layout->remove( m_used );
delete m_used;
m_used = NULL;
}
QLabel *total_label = static_cast<QLabel *>( child( "TotalLabel", "QLabel" ) );
if ( total_label )
{
m_layout->remove( total_label );
delete total_label;
}
if ( m_total )
{
m_layout->remove( m_total );
delete m_total;
m_total = NULL;
}
QLabel *usage_label = static_cast<QLabel *>( child( "UsageLabel", "QLabel" ) );
if ( usage_label )
{
m_layout->remove( usage_label );
delete usage_label;
}
if ( m_usage )
{
m_layout->remove( m_usage );
delete m_usage;
m_usage = NULL;
}
QFont font;
font.setItalic( true );
QLabel *error = new QLabel( i18n( "This share is inaccessible." ), this );
error->setFont( font );
error->show();
m_layout->remove( m_pixmap );
m_pixmap->setPixmap( m_item->desktopPixmap() );
m_layout->addMultiCellWidget( error, 5, 5, 1, 2, Qt::AlignCenter );
m_layout->addMultiCellWidget( m_pixmap, 0, 5, 0, 0, Qt::AlignCenter );
}
adjustSize();
}
void Smb4KSharesListViewToolTip::mousePressEvent( QMouseEvent *e )
{
hide();
QLabel::mousePressEvent( e );
}
void Smb4KSharesListViewToolTip::leaveEvent( QEvent *e )
{
hide();
QLabel::leaveEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSharesListViewToolTip::slotHideToolTip()
{
if ( isShown() )
{
hide();
}
}
#include "smb4kshareslistviewtooltip.moc"

@ -0,0 +1,160 @@
/***************************************************************************
smb4kshareslistviewtooltip - Tool tip for the shares list view.
-------------------
begin : So Jul 8 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSHARESLISTVIEWTOOLTIP_H
#define SMB4KSHARESLISTVIEWTOOLTIP_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qlabel.h>
#include <qpoint.h>
#include <qlayout.h>
// Forward declarations:
class Smb4KSharesListViewItem;
/**
* This class provides the tool tip for the shares list view
* of Smb4K. It shows information about the associated share.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSharesListViewToolTip : public QLabel
{
Q_OBJECT
public:
/**
* The constructor.
*
* Please note that the parent of the tool tip will be '0' and
* not the parent widget of @p item. Thus, you have to delete the
* tool tip object in the destructor of the parent widget.
*
* @param item The item for which the tool tip should be shown.
*/
Smb4KSharesListViewToolTip( Smb4KSharesListViewItem *item );
/**
* The destructor
*/
~Smb4KSharesListViewToolTip();
/**
* Show the tool tip. Please note that the tool tip will not be
* shown exactly at position @p pos but with a displacement of 5
* pixels in x- and y-direction.
*
* @param pos The global position of the mouse pointer.
*/
void showTip( const QPoint &pos );
/**
* The shares list view item for which the tool tip should be shown.
*
* @returns a pointer to a Smb4KSharesListViewItem object.
*/
Smb4KSharesListViewItem *item() { return m_item; }
/**
* Update the tool tip by rereading the contents of the shareObject()
* provided by the Smb4KSharesListViewItem. This function only changes
* those entries that might have changed such as the free and used disk
* space and the usage.
*/
void update();
protected:
/**
* Reimplemented from QLabel.
*/
void mousePressEvent( QMouseEvent *e );
/**
* Reimplemented from QLabel.
*/
void leaveEvent( QEvent *e );
protected slots:
/**
* This slot hides the tool tip after 10 sec.
*/
void slotHideToolTip();
private:
/**
* The item for which the tool tip should be shown
*/
Smb4KSharesListViewItem *m_item;
/**
* The layout of the tool tip.
*/
QGridLayout *m_layout;
/**
* This function sets up the tool tip.
*/
void setupTip();
/**
* Tells us if the tool tip has already been set up.
*/
bool m_is_set_up;
/**
* This label holds the variable value of the free
* space left on the share.
*/
QLabel *m_free;
/**
* This label holds the variable value of the used
* space on the share.
*/
QLabel *m_used;
/**
* This label holds the value of the total space
* available on the share.
*/
QLabel *m_total;
/**
* This label holds the variable value of the usage
*/
QLabel *m_usage;
/**
* This label holds the pixmap.
*/
QLabel *m_pixmap;
};
#endif

@ -0,0 +1,161 @@
/***************************************************************************
main.cpp - Main file of the Smb4K program.
-------------------
begin : Sam M<EFBFBD> 1 14:57:21 CET 2003
copyright : (C) 2003 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 *
***************************************************************************/
// Qt includes
#include <qstringlist.h>
#include <qfile.h>
// KDE includes
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kiconloader.h>
#include <dcopclient.h>
#include <kconfig.h>
#include <kuniqueapplication.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
// system includes
#include <stdlib.h>
// application specific includes
#include "smb4k.h"
#include "core/smb4ksettings.h"
#include "core/smb4kcore.h"
static const char *description =
I18N_NOOP( "Smb4K is an advanced network neighborhood browser and a\n"
"front end to the programs of the Samba software suite." );
static KCmdLineOptions options[] =
{
// { "+[File]", I18N_NOOP("file to open"), 0 },
{ 0, 0, 0 }
// INSERT YOUR COMMANDLINE OPTIONS HERE
};
int main( int argc, char *argv[] )
{
KAboutData aboutData( "smb4k", I18N_NOOP( "Smb4K" ),
VERSION, description, KAboutData::License_GPL,
I18N_NOOP( "(c) 2003-2008, Alexander Reinholdt\n(c) 2004-2008, Massimo Callegari\n(c) 2004, Franck Babin" ), 0, "http://smb4k.berlios.de", "smb4k-bugs@lists.berlios.de" );
// Authors:
aboutData.addAuthor( "Alexander Reinholdt", I18N_NOOP( "Developer" ), "dustpuppy@users.berlios.de" );
aboutData.addAuthor( "Massimo Callegari", I18N_NOOP( "Developer" ), "massimocallegari@yahoo.it" );
aboutData.addAuthor( "Franck Babin", I18N_NOOP( "Developer" ), "babinfranck@yahoo.ca" );
// All our credits:
aboutData.addCredit( "Leopold Palomo Avellaneda", I18N_NOOP( "Catalan translation" ), "lepalom@wol.es" );
aboutData.addCredit( "Radoslaw Zawartko", I18N_NOOP( "Polish translation" ), "radzaw@lnet.szn.pl" );
aboutData.addCredit( "Nick Chen", I18N_NOOP( "Chinese Simplified translation" ), "nick_chen75@hotmail.com" );
aboutData.addCredit( "Stanislav Yudin", I18N_NOOP( "Russian translation" ), "decvar@mail.berlios.de" );
aboutData.addCredit( "Marc Hansen", I18N_NOOP( "Swedish translation and intensive testing" ), "marc.hansen@gmx.de" );
aboutData.addCredit( "Giovanni Degani", I18N_NOOP( "Brazilian Portuguese translation" ), "tiefox@terra.com.br" );
aboutData.addCredit( "Ivan Petrouchtchak", I18N_NOOP( "Ukrainian translation" ), "iip@telus.net" );
aboutData.addCredit( "Karoly Barcza", I18N_NOOP( "Hungarian translation" ), "kbarcza@blackpanther.hu" );
aboutData.addCredit( "Quique", I18N_NOOP( "Spanish translation" ), "quique@sindominio.net" );
aboutData.addCredit( "Michal Šulek", I18N_NOOP( "Slovak translation" ), "reloadshot@atlas.sk" );
aboutData.addCredit( "Nicolas Ternisien", I18N_NOOP( "French translation" ), "nicolast@libertysurf.fr" );
aboutData.addCredit( "Toyohiro Asukai", I18N_NOOP( "Japanese translation" ), "toyohiro@ksmplus.com" );
aboutData.addCredit( "Atanas Mavrov", I18N_NOOP( "Bulgarian translation" ), "bugar@developer.bg" );
aboutData.addCredit( "Isidoro Russo", I18N_NOOP( "Italian translation" ), "risidoro@aliceposta.it" );
aboutData.addCredit( "Nils Kristian Tomren", I18N_NOOP( "Norwegian translations" ), "project@nilsk.net" );
aboutData.addCredit( "Alois Nešpor", I18N_NOOP( "Czech translation" ), "alois.nespor@seznam.cz" );
aboutData.addCredit( "Martín Carr", I18N_NOOP( "Spanish translation" ), "tincarr@gmail.com" );
aboutData.addCredit( "Görkem Çetin", I18N_NOOP( "Turkish translation" ), "gorkem@gorkemcetin.com" );
aboutData.addCredit( "Jack Liu", I18N_NOOP( "Chinese Traditional translation" ), "chuany@chuany.net" );
aboutData.addCredit( "Arnar Leósson", I18N_NOOP( "Icelandic translation" ), "leosson@frisurf.no" );
aboutData.addCredit( "Michael Brinkloev", I18N_NOOP( "Danish translation" ), "mhb@qxp.dk" );
aboutData.addCredit( "Joop Beris", I18N_NOOP( "Dutch translation" ), "jberis@risse.nl" );
aboutData.addCredit( "Lamarque V. Souza", I18N_NOOP( "Brazilian Portuguese translation" ), "lamarque_souza@hotmail.com" );
aboutData.addCredit( "Serdar Soytetir", I18N_NOOP( "Turkish translation" ), "sendirom@gmail.com" );
aboutData.addCredit( "Wei-Lun Chao", I18N_NOOP( "Chinese Traditional translation" ), "chaoweilun@users.berlios.de" );
aboutData.addCredit( "Rashid N. Achilov", I18N_NOOP( "Testing of Smb4K under FreeBSD" ), "shelton@sentry.granch.ru" );
aboutData.addCredit( "Jerzy Trzeciak", I18N_NOOP( "Polish translation" ), "artusek@wp.pl" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
KUniqueApplication::addCmdLineOptions();
// This is not needed, because KUniqueApplication::start()
// is called directly before the application is executed, but
// we use it anyway. There is no performance impact.
if ( !KUniqueApplication::start() )
{
exit( 0 );
}
KUniqueApplication app;
// Check the current config file and remove it if it belongs to
// a version < 0.9.0.
KConfig config( "smb4krc", false, false, "config" );
if ( !config.groupList().isEmpty() &&
(config.groupList().contains( "Browse Options" ) != 0 ||
config.groupList().contains( "Mount Options" ) != 0 ||
config.groupList().contains( "Rsync" ) != 0 ||
config.groupList().contains( "Super User Privileges") != 0 ||
config.groupList().contains( "User Interface" ) != 0 ||
config.groupList().contains( "System" ) != 0) )
{
int return_value = KMessageBox::warningContinueCancel( 0, i18n( "Smb4K now uses a different configuration system. Thus, your old settings are obsolete and you have to reconfigure the application.\nTo assure a clean transition, the current configuration file will be removed." ) );
if ( return_value == KMessageBox::Continue )
{
QString file_name = locateLocal( "config", "smb4krc", false );
if ( !file_name.isEmpty() && QFile::exists( file_name ) )
{
QFile::remove( file_name );
}
}
else
{
exit( 0 );
}
}
// Launch the application:
Smb4KApp *smb4k = new Smb4KApp( 0, "MainApp" );
app.setMainWidget( smb4k );
if ( !Smb4KSettings::embedIntoSystemTray() || !Smb4KSettings::startMainWindowDocked() )
{
smb4k->show();
}
Smb4KCore::self()->init();
int result = app.exec();
return result;
}

@ -0,0 +1,10 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO
kde_module_LTLIBRARIES = libsmb4ksearchdialog.la
libsmb4ksearchdialog_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
$(LIB_KDECORE) $(LIB_KDEUI) $(KDE_PLUGIN) $(LIB_KPARTS) $(LIB_QT)
noinst_HEADERS = smb4ksearchdialog.h smb4ksearchdialog_part.h \
smb4ksearchdialogitem.h
libsmb4ksearchdialog_la_SOURCES = smb4ksearchdialog.cpp \
smb4ksearchdialog_part.cpp smb4ksearchdialogitem.cpp
libsmb4ksearchdialog_la_LDFLAGS = -module -no-undefined $(all_libraries)

@ -0,0 +1,200 @@
/***************************************************************************
smb4ksearchdialog - The search dialog widget of Smb4K.
-------------------
begin : Sa Jun 2 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qlayout.h>
#include <qstringlist.h>
#include <qheader.h>
// KDE includes
#include <klocale.h>
#include <kdebug.h>
#include <kcombobox.h>
// application specific includes
#include "smb4ksearchdialog.h"
#include "smb4ksearchdialogitem.h"
#include "../core/smb4knetworkitems.h"
Smb4KSearchDialog::Smb4KSearchDialog( QWidget *parent, const char *name )
: QWidget( parent, name )
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 5 );
// Tool bar
m_tool_bar = new KToolBar( this, "SearchDialogToolBar", true, true );
m_tool_bar->insertCombo( QStringList(), Combo, true, SIGNAL( returnPressed() ),
this, SLOT( slotReturnPressed() ), true,
i18n( "Enter the search string here." ), -1, Combo );
m_tool_bar->setItemAutoSized( Combo, true );
m_tool_bar->insertSeparator();
m_tool_bar->insertButton( "find", Search, false, i18n( "Search" ) );
m_tool_bar->insertButton( "editdelete", Clear, false, i18n( "Clear" ) );
m_tool_bar->insertButton( "button_ok", Add, false, i18n( "Add" ) );
// List view
m_list_view = new KListView( this, "SearchDialogListView" );
m_list_view->addColumn( i18n( "Search Results" ), -1 );
m_list_view->header()->hide();
m_list_view->setSelectionMode( QListView::Single );
layout->addWidget( m_tool_bar, 0, 0, 0 );
layout->addWidget( m_list_view, 1, 0, 0 );
m_search_string = QString::null;
// Connections:
connect( m_tool_bar->getCombo( Combo ), SIGNAL( textChanged( const QString & ) ),
this, SLOT( slotTextChanged( const QString & ) ) );
connect( m_tool_bar, SIGNAL( pressed( int ) ),
this, SLOT( slotButtonPressed( int ) ) );
connect( m_list_view, SIGNAL( clicked( QListViewItem * ) ),
this, SLOT( slotItemClicked( QListViewItem * ) ) );
connect( m_list_view, SIGNAL( selectionChanged( QListViewItem * ) ),
this, SLOT( slotSelectionChanged( QListViewItem * ) ) );
}
Smb4KSearchDialog::~Smb4KSearchDialog()
{
}
const QString &Smb4KSearchDialog::searchString()
{
m_search_string = m_tool_bar->getCombo( Combo )->currentText();
return m_search_string;
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS
/////////////////////////////////////////////////////////////////////////////
void Smb4KSearchDialog::slotReturnPressed()
{
slotButtonPressed( Search );
}
void Smb4KSearchDialog::slotTextChanged( const QString &text )
{
m_tool_bar->setItemEnabled( Search, !text.isEmpty() );
m_tool_bar->setItemEnabled( Clear, !text.isEmpty() );
}
void Smb4KSearchDialog::slotButtonPressed( int button_id )
{
switch( button_id )
{
case Search:
{
// We will not remove the text from the edit line of the combo
// box like in earlier versions of Smb4K, but it will be selected
// later on, so that the user can easily remove it, if he wants to.
// We disable the combo box until the search process returns.
m_tool_bar->setItemEnabled( Combo, false );
break;
}
case Clear:
{
// Clear the combo box and the list view. The buttons
// will be disabled by slotTextChanged().
m_tool_bar->getCombo( Combo )->clear();
m_list_view->clear();
m_tool_bar->setItemEnabled( Search, false );
m_tool_bar->setItemEnabled( Clear, false );
m_tool_bar->setItemEnabled( Add, false );
break;
}
default:
{
break;
}
}
emit buttonPressed( button_id );
}
void Smb4KSearchDialog::slotItemClicked( QListViewItem *item )
{
if ( !item )
{
// If there is no item, it means that the user clicked onto
// the viewport. In this case, disable the "Add" button and
// clear the current selection.
m_tool_bar->setItemEnabled( Add, false );
m_list_view->clearSelection();
}
else
{
// This is done by slotSelectionChanged().
}
}
void Smb4KSearchDialog::slotSelectionChanged( QListViewItem *item )
{
if ( item )
{
// If we have got an item, enable the "Add" button if the
// item is regular. Otherwise disable the button.
Smb4KSearchDialogItem *search_item = static_cast<Smb4KSearchDialogItem *>( item );
if ( search_item->isRegular() )
{
m_tool_bar->setItemEnabled( Add, true );
}
else
{
m_tool_bar->setItemEnabled( Add, false );
}
}
else
{
// If there is no item, it means that the user clicked onto
// the viewport. In this case, disable the "Add" button and
// clear the current selection.
m_tool_bar->setItemEnabled( Add, false );
m_list_view->clearSelection();
}
}
#include "smb4ksearchdialog.moc"

@ -0,0 +1,173 @@
/***************************************************************************
smb4ksearchdialog - The search dialog widget of Smb4K.
-------------------
begin : Sa Jun 2 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSEARCHDIALOG_H
#define SMB4KSEARCHDIALOG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qwidget.h>
#include <qstring.h>
// KDE includes
#include <klistview.h>
#include <ktoolbar.h>
// forward declarations
class Smb4KHostItem;
/**
* This is the search dialog. It enables the user to find servers,
* that were not found by the regular network scan.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSearchDialog : public QWidget
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget
*
* @param name The name of this widget
*/
Smb4KSearchDialog( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KSearchDialog();
/**
* This enumeration determines the place where the tool bar
* widgets are located.
*/
enum ToolBarWidgets { Combo = 0, Search, Clear, Add };
/**
* Returns the search string the user entered. It's the current
* text of the combo box.
*
* @returns the search string.
*/
const QString &searchString();
/**
* This function returns a pointer to the list view of this widget.
*
* @returns a pointer to the list view of this widget.
*/
KListView *listView() { return m_list_view; }
/**
* This function returns a pointer to the tool bar of this widget.
*
* @returns a pointer to the tool bar of this widget.
*/
KToolBar *toolBar() { return m_tool_bar; }
signals:
/**
* This signal is emitted everytime a button of the tool bar
* or the return key has been clicked. It passes the button id
* according to the ToolBarWidgets enumeration.
*
* @param button_id The button id
*/
void buttonPressed( int button_id );
protected slots:
/**
* This slot is called when the search text has been entered
* and the return key has been pressed.
*/
void slotReturnPressed();
/**
* This slot is activated when the text in the edit line of the
* combo box changed. It is used to enable and disable buttons.
*
* @param text The text input
*/
void slotTextChanged( const QString &text );
/**
* This slot is activated when a button in the tool bar is pressed.
* It emits the buttonPressed() signal that can be processed by the
* KPart or other widgets. Additionally, it also executes those things
* that need not be done outside the widget, like clearing all the
* list box and the combo box.
*
* @param button_id The button id according to the ToolBarWidgets
* enumeration.
*/
void slotButtonPressed( int button_id );
/**
* This slot is activated when the user clicked into the list view. It
* is used to disable the "Add" button in the tool bar when no item is
* selected, i.e. the user clicked on the viewport. The rest is done by
* slotSelectionChanged().
*
* @param item The list box item that the user clicked or NULL if
* he clicked onto the viewport.
*/
void slotItemClicked( QListViewItem *item );
/**
* This slot is activated when the selection changed in the list view.
* It is used to enable/disable the "Add" button in the tool bar.
*
* @param item The list box item that's currently selected
*/
void slotSelectionChanged( QListViewItem *item );
private:
/**
* The current search string
*/
QString m_search_string;
/**
* The list box of this widget
*/
KListView *m_list_view;
/**
* The tool bar of this widget
*/
KToolBar *m_tool_bar;
};
#endif

@ -0,0 +1,277 @@
/***************************************************************************
smb4ksearchdialog_part - This Part encapsulates the search dialog
of Smb4K.
-------------------
begin : Fr Jun 1 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qimage.h>
#include <qpixmap.h>
// KDE includes
#include <kaboutdata.h>
#include <kinstance.h>
#include <kdebug.h>
#include <kiconeffect.h>
#include <kiconloader.h>
#include <kcombobox.h>
// application specific includes
#include "smb4ksearchdialog_part.h"
#include "smb4ksearchdialog.h"
#include "smb4ksearchdialogitem.h"
#include "../core/smb4kcore.h"
#include "../core/smb4knetworkitems.h"
#include "../core/smb4kdefs.h"
KInstance *Smb4KSearchDialogPartFactory::m_instance = 0L;
KAboutData *Smb4KSearchDialogPartFactory::m_about = 0L;
Smb4KSearchDialogPart::Smb4KSearchDialogPart( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name )
: KParts::Part( parent, name )
{
// First of all we need an instance:
setInstance( Smb4KSearchDialogPartFactory::instance() );
// Set the XML file:
// setXMLFile( "smb4ksearchdialog_part.rc" );
// Set the widget of this part:
m_widget = new Smb4KSearchDialog( parentWidget, widgetName );
setWidget( m_widget );
m_serial_number = 0;
// Connections:
connect( m_widget, SIGNAL( buttonPressed( int ) ),
this, SLOT( slotButtonPressed( int ) ) );
connect( m_widget->listView(), SIGNAL( doubleClicked( QListViewItem * ) ),
this, SLOT( slotItemDoubleClicked( QListViewItem * ) ) );
connect( Smb4KCore::scanner(), SIGNAL( searchResult( Smb4KHostItem * ) ),
this, SLOT( slotReceivedSearchResult( Smb4KHostItem * ) ) );
connect( Smb4KCore::scanner(), SIGNAL( hostListChanged() ),
this, SLOT( slotCheckItemIsKnown() ) );
}
Smb4KSearchDialogPart::~Smb4KSearchDialogPart()
{
}
void Smb4KSearchDialogPart::customEvent( QCustomEvent *e )
{
switch ( e->type() )
{
case EVENT_LOAD_SETTINGS:
{
// Not needed at the moment.
break;
}
case EVENT_SET_FOCUS:
{
m_widget->toolBar()->getCombo( Smb4KSearchDialog::Combo )->lineEdit()->setFocus();
break;
}
default:
{
break;
}
}
KParts::Part::customEvent( e );
}
/////////////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATIONS (Smb4KSearchDialogPart)
/////////////////////////////////////////////////////////////////////////////
void Smb4KSearchDialogPart::slotButtonPressed( int button_id )
{
switch ( button_id )
{
case Smb4KSearchDialog::Search:
{
Smb4KCore::scanner()->search( m_widget->searchString() );
break;
}
case Smb4KSearchDialog::Add:
{
Smb4KSearchDialogItem *search_item = static_cast<Smb4KSearchDialogItem *>( m_widget->listView()->currentItem() );
if ( search_item && !search_item->isKnown() )
{
Smb4KCore::scanner()->insertHost( search_item->hostItem() );
}
else
{
// Do nothing
}
break;
}
default:
{
break;
}
}
}
void Smb4KSearchDialogPart::slotReceivedSearchResult( Smb4KHostItem *item )
{
if ( item )
{
// Create a Smb4KSearchDialogItem. This will also add it
// to the list box.
(void) new Smb4KSearchDialogItem( m_widget->listView(), item, m_serial_number++ );
// Enable the combo box and set the focus:
m_widget->toolBar()->setItemEnabled( Smb4KSearchDialog::Combo, true );
m_widget->toolBar()->getCombo( Smb4KSearchDialog::Combo )->setFocus();
// Now select the text, so that the user can easily
// remove it.
int string_length = m_widget->toolBar()->getCombo( Smb4KSearchDialog::Combo )->lineEdit()->text().length();
m_widget->toolBar()->getCombo( Smb4KSearchDialog::Combo )->lineEdit()->setSelection( 0, string_length );
slotCheckItemIsKnown();
}
}
void Smb4KSearchDialogPart::slotCheckItemIsKnown()
{
QListViewItemIterator it( m_widget->listView() );
while ( it.current() )
{
Smb4KSearchDialogItem *item = static_cast<Smb4KSearchDialogItem *>( it.current() );
if ( item && item->isRegular() )
{
Smb4KHostItem *host = Smb4KCore::scanner()->getHost( item->hostItem()->name(), item->hostItem()->workgroup() );
item->setKnown( (host ? true : false) );
}
else
{
// Do nothing
}
++it;
}
}
void Smb4KSearchDialogPart::slotItemDoubleClicked( QListViewItem *item )
{
if ( item )
{
// If we have got an item, enable the "Add" button if the
// item is regular. Otherwise disable the button.
Smb4KSearchDialogItem *search_item = static_cast<Smb4KSearchDialogItem *>( item );
if ( search_item && search_item->isRegular() && !search_item->isKnown() )
{
Smb4KCore::scanner()->insertHost( search_item->hostItem() );
}
else
{
// Do nothing
}
}
}
/////////////////////////////////////////////////////////////////////////////
// FACTORY STUFF
/////////////////////////////////////////////////////////////////////////////
Smb4KSearchDialogPartFactory::Smb4KSearchDialogPartFactory()
: KParts::Factory()
{
}
Smb4KSearchDialogPartFactory::~Smb4KSearchDialogPartFactory()
{
delete m_instance;
delete m_about;
m_instance = 0L;
}
KParts::Part *Smb4KSearchDialogPartFactory::createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name, const char *, const QStringList & )
{
Smb4KSearchDialogPart *obj = new Smb4KSearchDialogPart( parentWidget, widgetName, parent, name );
// See if we are to be read-write or not
// if (QCString(classname) == "KParts::ReadOnlyPart")
// {
// obj->setReadWrite(false);
// }
return obj;
}
KInstance *Smb4KSearchDialogPartFactory::instance()
{
if( !m_instance )
{
m_about = new KAboutData( "smb4ksearchdialogpart", I18N_NOOP( "Smb4KSearchDialogPart" ), "1.0" );
m_about->addAuthor("Alexander Reinholdt", 0, "dustpuppy@users.berlios.de");
m_about->setLicense( KAboutData::License_GPL );
m_instance = new KInstance( m_about );
}
return m_instance;
}
/////////////////////////////////////////////////////////////////////////////
// INIT
/////////////////////////////////////////////////////////////////////////////
extern "C"
{
void *init_libsmb4ksearchdialog()
{
KGlobal::locale()->insertCatalogue( "smb4k" );
return new Smb4KSearchDialogPartFactory;
}
}
#include "smb4ksearchdialog_part.moc"

@ -0,0 +1,171 @@
/***************************************************************************
smb4ksearchdialog_part - This Part encapsulates the search dialog
of Smb4K.
-------------------
begin : Fr Jun 1 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSEARCHDIALOGPART_H
#define SMB4KSEARCHDIALOGPART_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <qlistview.h>
// KDE includes
#include <kparts/part.h>
#include <kparts/factory.h>
// forward declarations
class Smb4KSearchDialog;
class Smb4KHostItem;
/**
* This is one of the parts of Smb4K. It contains the search dialog.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSearchDialogPart : public KParts::Part
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parentWidget The parent widget
*
* @param widgetName The name the widget should have
*
* @param parent The parent object
*
* @param name The name this object should have
*/
Smb4KSearchDialogPart( QWidget *parentWidget = 0, const char *widgetName = 0,
QObject *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
virtual ~Smb4KSearchDialogPart();
protected:
/**
* Reimplemented from KParts::Part.
*/
void customEvent( QCustomEvent *e );
protected slots:
/**
* This slot is connected to the Smb4KSearchDialog::buttonPressed()
* signal. It initializes the search process, etc.
*
* @param button_id The button id according to
* Smb4KSearchDialog::ToolBarWidgets.
*/
void slotButtonPressed( int button_id );
/**
* This slot retrieves the search result and puts it into the search
* dialog.
*
* @param item A Smb4KHostItem object
*/
void slotReceivedSearchResult( Smb4KHostItem *item );
/**
* This slot is connected to the Smb4KScanner::hostListChanged() signal
* and checks whether the host is already known, i.e. it is in the browser,
* or if it is "new". If it is already known, this slot will change the icon
* of the host item from the default one to one with a tick layed over.
*/
void slotCheckItemIsKnown();
/**
* This slot is invoked, when a user double clicks an item. It adds the item
* to the list of known hosts (if necessary).
*
* @param item The item that has been double clicked.
*/
void slotItemDoubleClicked( QListViewItem *item );
private:
/**
* This is the actual search dialog widget.
*/
Smb4KSearchDialog *m_widget;
/**
* Work around insertion "problems" of the search dialog items.
*/
int m_serial_number;
};
class KInstance;
class KAboutData;
class Smb4KSearchDialogPartFactory : public KParts::Factory
{
Q_OBJECT
public:
/**
* The constructor
*/
Smb4KSearchDialogPartFactory();
/**
* The destructor
*/
virtual ~Smb4KSearchDialogPartFactory();
/**
* Reimplemented from KParts::Factory
*/
virtual KParts::Part *createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const char *classname, const QStringList &args );
/**
* The instance
*/
static KInstance *instance();
private:
/**
* The factory's instance.
*/
static KInstance *m_instance;
/**
* The factory's KAboutData object
*/
static KAboutData *m_about;
};
#endif

@ -0,0 +1,140 @@
/***************************************************************************
smb4ksearchdialogitem - This class is an enhanced version of a list
box item for Smb4K.
-------------------
begin : So Jun 3 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
// Qt includes
#include <qimage.h>
// KDE includes
#include <kiconloader.h>
#include <kiconeffect.h>
#include <klocale.h>
// application specific includes
#include "smb4ksearchdialogitem.h"
#include "smb4ksearchdialog.h"
#include "../core/smb4knetworkitems.h"
Smb4KSearchDialogItem::Smb4KSearchDialogItem( KListView *listView, Smb4KHostItem *item, int serial )
: KListViewItem( listView ), m_item( *item ), m_serial( serial )
{
m_is_known = false;
if ( !m_item.name().isEmpty() )
{
m_is_regular = true;
QString item_text = m_item.name();
if ( !m_item.workgroup().isEmpty() && !m_item.ip().isEmpty() )
{
item_text.append( " ["+m_item.workgroup()+", "+m_item.ip()+"]" );
}
else
{
if ( !m_item.workgroup().isEmpty() )
{
item_text.append( " ["+m_item.workgroup()+"]" );
}
else if ( !m_item.ip().isEmpty() )
{
// This case will most likely never appear.
item_text.append( " ["+m_item.ip()+"]" );
}
else
{
// Add nothing to the item text.
}
}
setText( 0, item_text );
setIcon();
}
else
{
m_is_regular = false;
setText( 0, i18n( "The search failed." ) );
setIcon();
}
}
Smb4KSearchDialogItem::~Smb4KSearchDialogItem()
{
}
void Smb4KSearchDialogItem::setIcon()
{
if ( m_is_regular )
{
if ( m_is_known )
{
KIconEffect e;
QImage over = SmallIcon( "button_ok" ).convertToImage();
QImage src = SmallIcon( "server" ).convertToImage();
e.semiTransparent( over );
e.overlay( src, over );
QPixmap pix( src );
setPixmap( 0, pix );
}
else
{
setPixmap( 0, SmallIcon( "server" ) );
}
}
else
{
setPixmap( 0, SmallIcon( "no" ) );
}
}
void Smb4KSearchDialogItem::setKnown( bool known )
{
m_is_known = known;
setIcon();
}
int Smb4KSearchDialogItem::compare( QListViewItem *i, int, bool ascending ) const
{
Smb4KSearchDialogItem *item = static_cast<Smb4KSearchDialogItem *>( i );
int result = 0;
if ( item )
{
result = item->serialNumber() - serialNumber();
}
return (ascending ? result : -result);
}

@ -0,0 +1,166 @@
/***************************************************************************
smb4ksearchdialogitem - This class is an enhanced version of a list
box item for Smb4K.
-------------------
begin : So Jun 3 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSEARCHDIALOGITEM_H
#define SMB4KSEARCHDIALOGITEM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Qt includes
#include <klistview.h>
// application specific includes
#include "../core/smb4knetworkitems.h"
/**
* This class is an enhanced version of KListViewItem, that is used
* by the search dialog of Smb4K to show the search results. It
* encapsulates a Smb4KHostItem which carries all the information needed.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KSearchDialog;
class Smb4KSearchDialogItem : public KListViewItem
{
public:
/**
* The constructor. It will construct an list view item and set its
* text according to the contents of @p item. If the search failed
* and @p item is empty, an error message will be displayed.
*
* @param listBox The parent list box.
*
* @param item The host item that represents the search
* result.
*
* @param serial The user supplied serial number of this item. It
* is used for sorting. See compare() for further information.
*/
Smb4KSearchDialogItem( KListView *listView, Smb4KHostItem *item, int serial = 0 );
/**
* The destructor
*/
~Smb4KSearchDialogItem();
/**
* This function returns the Smb4KHostItem object that is encapsulated
* here.
*
* Make sure you copy the contents to a new item, because the pointer
* will be invalidated if this Smb4KSearchDialogItem is deleted.
*
* @returns the encapsulated Smb4KHostItem object.
*/
Smb4KHostItem *hostItem() { return &m_item; }
/**
* This function returns TRUE, if the item is regular, that means it
* represents a host. If it represents a failed search, it returns
* FALSE.
*
* @returns TRUE is the item is a regular one.
*/
bool isRegular() { return m_is_regular; }
/**
* This function notifies the item that the host that it represents is
* known to the application, i.e. it is in the list of hosts. It will set
* the pixmap accordingly and sets m_is_known.
*
* @param known Should be TRUE is the host is known.
*/
void setKnown( bool known );
/**
* This function returns TRUE, if the item is already known by the scanner.
*
* @returns TRUE is the item is already known.
*/
bool isKnown() { return m_is_known; }
/**
* This function is used for sorting.
*
* @returns the serial number of this item.
*/
int serialNumber() const { return m_serial; }
/**
* Reimplemented from QListViewItem. It is used for sorting and compares the
* serial numbers of this item and @p item. If @p ascending is TRUE and the
* serial number of this item is greater than that of @p item, it will be inserted
* before @p item and else it will be inserted after. In this implementation,
* @p col is *not* used.
*
* @param item The list view item with that this one is compared.
*
* @param col The column that should be used for sorting. It is
* not used in this implementation.
*
* @param ascending Sort ascending if TRUE or descending if FALSE.
*
* @returns 0 if serialNumber() and @p item->serialNumber() are equal and != 0 if
* they are not. Which value and especially which algebraic sign is returned depends
* on the values that are returned by of both serialNumber() functions and on @p ascending.
*/
int compare( QListViewItem *item, int col, bool ascending ) const;
private:
/**
* The Smb4KHostItem object
*/
Smb4KHostItem m_item;
/**
* TRUE, if we have a regular item
*/
bool m_is_regular;
/**
* TRUE is the item is known
*/
bool m_is_known;
/**
* This function sets the icon of the item. It looks at m_is_known and
* m_is_regular to decide which icon to choose.
*/
void setIcon();
/**
* The user defined index of this item.
*/
int m_serial;
};
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,81 @@
# KDE Config File
[Desktop Entry]
Name=Smb4K
GenericName=The SMB/CIFS Share Browser
GenericName[bg]=Самба ресурсен четец
GenericName[ca]=El navegador de compartits SMB/CIFS
GenericName[cs]=Prohližeč SMB/CIFS sdílení
GenericName[da]=SMB/CIFS ressource browseren
GenericName[de]=Der Browser für SMB/CIFS-Freigaben
GenericName[es]=El explorador de recursos compartidos SMB/CIFS
GenericName[fr]=L'explorateur de partages SMB / CIFS
GenericName[hu]=Az SMB/CIFS böngésző
GenericName[is]=SMB/CIFS sameignarflakkarinn
GenericName[it]=Browser di condivisioni SMB/CIFS
GenericName[ja]=SMB/CIFS 共有(シェア)・ブラウザー
GenericName[nb]=SMB/CIFS ressursutforsker
GenericName[nl]=De SMB/CIFS Share Browser
GenericName[nn]=SMB/CIFS ressurs-surfar
GenericName[pl]=Przeglądarka Zasobów SMB/CIFS
GenericName[pt_BR]=O navegador de compartilhamentos SMB/CIFS
GenericName[ru]=The SMB/CIFS Share Browser
GenericName[sk]=Prehliadač SMB/CIFS zdieľaní
GenericName[sv]=SMB Katalog programmed
GenericName[tr]=The SMB/CIFS Share Browser
GenericName[uk]=Навігатор спільних ресурсів SMB/CIFS
GenericName[zh_CN]=SMB 共享浏览器
#
# The following lines seem to be necessary for SuSE.
#
Name[bg]=Smb4K
Name[ca]=Smb4K
Name[cs]=Smb4K
Name[da]=Smb4K
Name[de]=Smb4K
Name[es]=Smb4K
Name[fr]=Smb4K
Name[hu]=Smb4K
Name[is]=Smb4K
Name[it]=Smb4K
Name[ja]=Smb4K
Name[nb]=Smb4K
Name[nl]=Smb4K
Name[nn]=Smb4K
Name[pl]=Smb4K
Name[pt_BR]=Smb4K
Name[ru]=Smb4K
Name[sk]=Smb4K
Name[sv]=Smb4K
Name[tr]=Smb4K
Name[uk]=Smb4K
Name[zh_CN]=Smb4K
Comment=The SMB/CIFS Share Browser
Comment[bg]=Самба ресурсен четец
Comment[ca]=El navegador de compartits SMB/CIFS
Comment[cs]=Prohližeč SMB/CIFS sdílení
Comment[da]=SMB/CIFS ressource browseren
Comment[de]=Der Browser für SMB/CIFS-Freigaben
Comment[es]=El explorador de recursos compartidos SMB/CIFS
Comment[fr]=L'explorateur de partages SMB / CIFS
Comment[hu]=Az SMB/CIFS böngésző
Comment[is]=SMB/CIFS sameignarflakkarinn
Comment[it]=Browser di condivisioni SMB/CIFS
Comment[ja]=SMB/CIFS 共有(シェア)・ブラウザー
Comment[nb]=SMB/CIFS ressursutforsker
Comment[nl]=De SMB/CIFS Share Browser
Comment[nn]=SMB/CIFS ressurs-surfar
Comment[pl]=Przeglądarka Zasobów SMB/CIFS
Comment[pt_BR]=O navegador de compartilhamentos SMB/CIFS
Comment[ru]=The SMB/CIFS Share Browser
Comment[sk]=Prehliadač SMB/CIFS zdieľaní
Comment[sv]=SMB Katalog programmed
Comment[tr]=The SMB/CIFS Share Browser
Comment[uk]=Навігатор спільних ресурсів SMB/CIFS
Comment[zh_CN]=SMB 共享浏览器
Exec=smb4k
Icon=smb4k
X-DocPath=smb4k/index.html
Type=Application
Terminal=false
Categories=Qt;KDE;Utility;
X-DCOP-ServiceType=Unique

@ -0,0 +1,229 @@
/***************************************************************************
smb4k.h - The main class of Smb4K.
-------------------
begin : Sam M<EFBFBD> 1 14:57:21 CET 2003
copyright : (C) 2003-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4K_H
#define SMB4K_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <kaction.h>
#include <kparts/dockmainwindow.h>
// Forward declarations
class Smb4KSystemTray;
/**
* This is the application shell of Smb4K.
*
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
*/
class Smb4KApp : public KParts::DockMainWindow
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent of this widget
*
* @param name The name of this widget
*/
Smb4KApp( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KApp();
protected:
/**
* Reimplemented from KMainWindow.
*/
bool queryExit();
/**
* Reimplemented from KMainWindow.
*/
bool queryClose();
/**
* Reimplemented from QObject
*/
void timerEvent( QTimerEvent *e );
protected slots:
/**
* Quit the application.
*/
void slotQuit();
/**
* Replace the current shares view.
*/
void slotChangeSharesView();
/**
* Open the configuration dialog. This slot is connected to the "Configure Smb4K..."
* action.
*/
void slotConfigDialog();
/**
* This slot is invoked when the config dialog is closed and the settings have
* been changed. Emits the reloadSettings() signal and adjusts the system tray
* widget to the new settings afterwards.
*/
void slotSettingsChanged();
/**
* Open the bookmark editor. This slot is connected to the "Edit Bookmarks"
* action.
*/
void slotBookmarkEditor();
/**
* Show a message to the user what currently is done by the application. This
* slot is connected to the Smb4KCore::runStateChanged() signal.
*/
void slotRunStateChanged();
/**
* This slot is invoked when the bookmarks have been updated. It inserts the
* bookmarks into the menu. Additionally, it enables the "Edit Bookmarks"
* action if there are bookmarks and else disables it.
*/
void slotSetupBookmarksMenu();
/**
* This slot is invoked when/if a bookmark is activated.
*/
void slotBookmarkActivated();
/**
* This slot is activated when the list of mounted shares has been updated.
* It is connected to the Smb4KMounter::updated() signal.
*/
void slotShareListUpdated();
/**
* This slot is activated when an action is highlighted and lets m_action
* point to it. No validity checks are performed.
*
* @param action The action that has been highlighted
*/
void slotActionHighlighted( KAction *action );
/**
* This slot sets the keyboard focus to the network browser and shows it
* if it is not already shown.
*/
void slotJumpToNetworkBrowser();
/**
* This slot sets the keyboard focus to the search dialog and shows it
* if it is not already shown.
*/
void slotJumpToSearchDialog();
/**
* This slot sets the keyboard focus to the shares view. Since it is the
* main widget, this slot does not care about it being hidden.
*/
void slotJumpToSharesView();
private:
/**
* Set up actions.
*/
void setupActions();
/**
* Set up the view.
*/
void setupView();
/**
* Set up the status bar
*/
void setupStatusBar();
/**
* Set up the system tray
*/
void setupSystemTray();
/**
* Change the shares view.
*/
void changeSharesView();
/**
* The shares view part
*/
KParts::Part *m_shares_part;
/**
* The browser part
*/
KParts::Part *m_browser_part;
/**
* The search dialog part
*/
KParts::Part *m_search_part;
/**
* The system tray icon of this application
*/
Smb4KSystemTray *m_system_tray;
/**
* Enumeration for the status bar
*/
enum StatusBarItem{ Message = 0, Progress = 1, Version = 2 };
/**
* The currently highlighted KAction.
*/
KAction *m_action;
/**
* This holds the config entry of the current shares
* view. This is used to avoid unnecessary loading.
*/
int m_current_shares_view;
/**
* The timer id
*/
int m_timer_id;
};
#endif

@ -0,0 +1,37 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="smb4k_shell" version="2">
<MenuBar>
<Menu noMerge="1" name="file"><text>&amp;File</text>
<Action name="quit_action"/>
</Menu>
<Menu noMerge="1" name="network"><text>&amp;Network</text>
</Menu>
<Menu noMerge="1" name="shares"><text>Sh&amp;ares</text>
</Menu>
<Menu noMerge="1" name="bookmarks"><text>&amp;Bookmarks</text>
<!-- This menu will dynamically be filled by Smb4KApp. -->
<ActionList name="bookmark_actions"/>
<ActionList name="bookmarks"/>
</Menu>
<Menu noMerge="1" name="settings"><text>&amp;Settings</text>
<Merge name ="StandardToolBarMenuHandler"/>
<Action name="options_show_statusbar"/>
<Separator/>
<Merge/>
<Action name="view_modes_menu"/>
<Separator/>
<Action name="configure_action"/>
</Menu>
</MenuBar>
<!-- fullWidth="false" shortens the tool bar, so that it looks nicer. -->
<ToolBar fullWidth="false" name="networkToolBar" index="0"><text>Network ToolBar</text>
</ToolBar>
<ToolBar fullWidth="false" name="sharesViewToolBar" index="1"><text>Shares View ToolBar</text>
</ToolBar>
<ToolBar fullWidth="true" noMerge="1" name="mainToolBar" index="2"><text>Main ToolBar</text>
<Action name="view_modes_menu"/>
<Action name="configure_action"/>
<Separator/>
<Action name="quit_action"/>
</ToolBar>
</kpartgui>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,207 @@
/***************************************************************************
smb4ksystemtray - This is the system tray window class of Smb4K.
-------------------
begin : Mi Jun 13 2007
copyright : (C) 2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifndef SMB4KSYSTEMTRAY_H
#define SMB4KSYSTEMTRAY_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// KDE includes
#include <ksystemtray.h>
#include <kactionclasses.h>
class Smb4KSystemTray : public KSystemTray
{
Q_OBJECT
public:
/**
* The constructor.
*
* @param parent The parent widget of the system tray window
*
* @param name The name of the system tray window
*/
Smb4KSystemTray( QWidget *parent = 0, const char *name = 0 );
/**
* The destructor.
*/
~Smb4KSystemTray();
/**
* Embeds the system tray window into the system tray, if @p ebd is
* TRUE. Otherwise, it removes it from there. Note, that the system tray
* icon won't be deleted but only hidden!
*
* @param ebd If TRUE the system tray icon will be embedded into
* the system tray.
*/
void embed( bool ebd );
/**
* This function returns TRUE if the system tray window is embedded into
* the system tray and FALSE otherwise.
*
* @returns TRUE if the system tray window is embedded.
*/
bool isEmbedded() { return isShown(); }
/**
* This function (re-)loads the settings for this widget. It basically just
* runs the slot slotSetupBookmarkMenu() and slotSetupSharesMenu(), that will
* do everything to properly set up the menus.
*
* This slot *does not* manage the appearance (or disappearance) of this widget
* in the system tray. You need to use embed() to do this.
*/
void loadSettings();
signals:
/**
* This signal is emitted when the config dialog has been closed and the
* settings changed.
*/
void settingsChanged();
protected slots:
/**
* This slot opens the dialog for mounting shares manually.
*/
void slotMountManually();
/**
* This slot opens the configurations dialog.
*/
void slotConfigDialog();
/**
* This slot is invoked when the config dialog is closed and the settings have
* been changed. Emits the reloadSettings() signal and adjusts the system tray
* widget to the new settings afterwards.
*/
void slotSettingsChanged();
/**
* This slot is invoked when the bookmarks have been updated. It sets up the
* bookmark menu, inserts the bookmark actions into it and automatically
* disables them if they were already mounted (@see slotSetupSharesMenu() as well).
*/
void slotSetupBookmarksMenu();
/**
* This slot opens the bookmark editor.
*/
void slotBookmarkEditor();
/**
* This slot is called when a bookmark has been activated. It initializes the
* mounting of the represented share.
*/
void slotBookmarkActivated();
/**
* This slot enables and disables the bookmarks. If a share that's represented
* by the bookmark is mounted, the bookmark will be disabled. It will be
* enabled, when it is unmounted again.
*/
void slotEnableBookmarks();
/**
* This slot is activated when the list of mounted shares has been updated.
* It setus up the "Mounted Shares" menu and also enables/disables the
* bookmarks in the "Bookmarks" menu. It is connected to the
* Smb4KMounter::updated() signal.
*/
void slotSetupSharesMenu();
/**
* This slot initializes the umounting of all shares. It is connected to the
* "Unmount All" action of the "Mounted Shares" menu.
*/
void slotUnmountAllShares();
/**
* This slot is connected to the 'Unmount action'. You will be able to
* unmount a certain share when activating this slot.
*/
void slotUnmountShare();
/**
* This slot is connected to the 'Force Unmounting' action and is, thus,
* only useful under Linux, because only there the possibility for a forced
* (i.e. lazy) unmount exists.
*
* When activating this slot, the selected share will be unmounted, even if
* it is not accessible or the server already went offline.
*/
void slotForceUnmountShare();
/**
* This slot is connected to the 'Synchronize' action. The current item will be
* synchronized with a local copy (or vice versa) if you activate it.
*/
void slotSynchronize();
/**
* This slot is connected to the 'Konsole' action. The mount point of the current
* share item will be opened in Konsole.
*/
void slotKonsole();
/**
* This slot is connected to the 'Konqueror' action. The contents of the current
* share item will be opened in the file manager.
*/
void slotFilemanager();
/**
* This slot is enabled when an action is highlighted. No validity checks are
* performed.
*
* @param action The currently highlighted action.
*/
void slotActionHighlighted( KAction *action );
private:
/**
* The action menu for the bookmarks.
*/
KActionMenu *m_bookmarks_menu;
/**
* The action menu for the mounted shares.
*/
KActionMenu *m_shares_menu;
/**
* This is the currently highlighted action.
*/
KAction *m_action;
};
#endif

@ -0,0 +1,5 @@
doc
plugin
po
smb4k
utilities

@ -0,0 +1,14 @@
INCLUDES =
METASOURCES = AUTO
bin_PROGRAMS = smb4k_mount smb4k_umount smb4k_kill smb4k_cat smb4k_mv
smb4k_mount_LDFLAGS = $(all_libraries)
smb4k_umount_LDFLAGS = $(all_libraries)
smb4k_kill_LDFLAGS = $(all_libraries)
smb4k_umount_SOURCES = smb4k_umount.cpp
smb4k_mount_SOURCES = smb4k_mount.cpp
smb4k_kill_SOURCES = smb4k_kill.cpp
smb4k_cat_LDFLAGS = $(all_libraries)
smb4k_cat_SOURCES = smb4k_cat.cpp
smb4k_mv_LDFLAGS = $(all_libraries)
smb4k_mv_SOURCES = smb4k_mv.cpp

@ -0,0 +1,206 @@
/***************************************************************************
smb4k_cat - This utility behaves essentially like 'cat'. It is
used to "read" system configuration files and is part of Smb4K.
-------------------
begin : Mi Nov 2 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <locale.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iostream>
using namespace std;
#define MAX_LINE_LENGTH 1024
#define SMB4K_CAT_VERSION "0.8"
void info()
{
cout << "This is smb4k_cat (version " << SMB4K_CAT_VERSION << "), the cat utility of Smb4K" << endl;
cout << "Copyright (C) 2005-2007, Alexander Reinholdt" << endl;
cout << endl;
cout << "Usage:" << endl;
cout << " smb4k_cat {file}" << endl;
cout << " smb4k_cat --help" << endl;
cout << " smb4k_cat --version" << endl;
cout << endl;
cout << "Arguments:" << endl;
cout << " {file}\tThe (full) path of the file that should be printed to stdout." << endl;
cout << endl;
cout << " --help\tDisplay this help screen and exit." << endl;
cout << " --version\tDisplay the version information and exit." << endl;
cout << endl;
}
void version()
{
cout << "Version: " << SMB4K_CAT_VERSION << endl;
}
int main( int argc, char *argv[] )
{
(void) setlocale( LC_ALL, "" );
if ( argc < 2 )
{
info();
exit( EXIT_FAILURE );
}
char *filename = NULL;
int c;
while ( 1 )
{
int option_index = 0;
static struct option long_options[] =
{
{ "help", 0, 0, 0 },
{ "version", 0, 0, 0 },
{ 0, 0, 0, 0 }
};
c = getopt_long( argc, argv, "", long_options, &option_index );
if ( c == -1 )
{
break;
}
switch ( c )
{
case 0:
{
int len = strlen( long_options[option_index].name ) + 1;
char opt[len];
opt[0] = '\0';
(void) strncpy( opt, long_options[option_index].name, len );
opt[len-1] = '\0';
if ( !strncmp( opt, "help", len ) )
{
info();
exit( EXIT_SUCCESS );
}
else if ( !strncmp( opt, "version", len ) )
{
version();
exit( EXIT_SUCCESS );
}
else
{
break;
}
break;
}
case '?':
{
// Abort the program if an unknown option
// is encountered:
exit( EXIT_FAILURE );
}
default:
{
break;
}
}
}
if ( optind < argc )
{
// If we have an existing regular file, read it,
// display its contents and exit.
while ( optind < argc )
{
struct stat file_stat;
if ( lstat( argv[optind], &file_stat ) == -1 )
{
int err = errno;
cerr << "smb4k_cat: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
if ( !filename )
{
int len = strlen( argv[optind] ) + 1;
filename = new char[len];
filename[0] = '\0';
(void) strncpy( filename, argv[optind], len );
filename[len-1] = '\0';
}
else
{
break;
}
optind++;
}
}
if ( filename )
{
FILE *fd;
if ( (fd = fopen( filename, "r" )) == NULL )
{
int err = errno;
cerr << "smb4k_cat: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
char line[MAX_LINE_LENGTH];
line[0] = '\0';
while ( fgets( line, MAX_LINE_LENGTH, fd ) != NULL )
{
cout << line;
}
fclose( fd );
}
else
{
// This is redundant, but we'll keep it regardless.
cerr << "smb4k_cat: No file specified" << endl;
exit( EXIT_FAILURE );
}
exit( EXIT_SUCCESS );
}

@ -0,0 +1,228 @@
/***************************************************************************
smb4k_kill - This is the kill utility for Smb4K.
-------------------
begin : So Sep 26 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <locale.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define SMB4K_KILL_VERSION "0.7"
void info()
{
cout << "This is smb4k_kill (version " << SMB4K_KILL_VERSION << "), the kill utility of Smb4K" << endl;
cout << "Copyright (C) 2004-2007, Alexander Reinholdt" << endl;
cout << endl;
cout << "Usage:" << endl;
cout << " smb4k_kill {pid}" << endl;
cout << " smb4k_kill --help" << endl;
cout << " smb4k_kill --version" << endl;
cout << endl;
cout << "Arguments:" << endl;
cout << " {pid}\t\tThe ID of the process that should be terminated." << endl;
cout << endl;
cout << " --help\tDisplay this help screen and exit." << endl;
cout << " --version\tDisplay the version information and exit." << endl;
cout << endl;
}
void version()
{
cout << "Version: " << SMB4K_KILL_VERSION << endl;
}
bool find_program( const char *name, char *path )
{
const char *paths[] = { "/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/", "/usr/local/bin/", "/usr/local/sbin/" };
string file = "";
for ( uint i = 0; i < sizeof( paths ) / sizeof( char * ); i++ )
{
string p( paths[i] );
p.append( name );
if ( access( p.c_str(), X_OK ) == 0 )
{
file.assign( p );
break;
}
}
if ( !strcmp( file.c_str(), "" ) )
{
cerr << "smb4k_kill: Could not find " << name << " binary" << endl;
return false;
}
int len = strlen( file.c_str() ) + 1;
(void) strncpy( path, file.c_str(), len );
path[len-1] = '\0';
return true;
}
int main( int argc, char *argv[], char *envp[] )
{
// Set the locale:
(void) setlocale( LC_ALL, "" );
if ( argc < 2 )
{
info();
exit( EXIT_FAILURE );
}
int new_argc = argc + 1;
char *new_argv[new_argc];
int index = 0;
char path[255];
path[0] = '\0';
// Get the options that were passed.
int c;
while ( 1 )
{
int option_index = 0;
static struct option long_options[] =
{
{ "help", 0, 0, 0 },
{ "version", 0, 0, 0 },
{ 0, 0, 0, 0 }
};
c = getopt_long( argc, argv, "", long_options, &option_index );
if ( c == -1 )
{
break;
}
switch ( c )
{
case 0:
{
// Copy the option:
int len = strlen( long_options[option_index].name ) + 1;
char opt[len];
opt[0] = '\0';
(void) strncpy( opt, long_options[option_index].name, len );
opt[len-1] = '\0';
// Now check which option has been provided:
if ( !strncmp( opt, "help", len ) )
{
info();
exit( EXIT_SUCCESS );
}
else if ( !strncmp( opt, "version", len ) )
{
version();
exit( EXIT_SUCCESS );
}
else
{
break;
}
break;
}
case '?':
{
// Abort the program if an unknown option
// is encountered:
exit( EXIT_FAILURE );
}
default:
{
break;
}
}
}
if ( !find_program( "kill", path ) )
{
exit( EXIT_FAILURE );
}
int len = strlen( path ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], path, len );
new_argv[index][len-1] = '\0';
index++;
if ( optind < argc )
{
while ( optind < argc )
{
len = strlen( argv[optind] ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], argv[optind], len );
new_argv[index][len-1] = '\0';
optind++;
index++;
}
}
if ( index >= new_argc )
{
cerr << "smb4k_kill: There are too many arguments" << endl;
exit( EXIT_FAILURE );
}
// Terminate the new argv:
new_argv[index] = NULL;
// Execute command:
if ( execve( new_argv[0], new_argv, envp ) == -1 )
{
int err = errno;
cerr << "smb4k_kill: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
return EXIT_SUCCESS;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,388 @@
/***************************************************************************
smb4k_mv - This is the move utility of Smb4K
-------------------
begin : Sa Nov 19 2005
copyright : (C) 2005-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <locale.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define SMB4K_MV_VERSION "0.4"
void info()
{
cout << "This is smb4k_mv (version " << SMB4K_MV_VERSION << "), the move utility of Smb4K" << endl;
cout << "Copyright (C) 2005-2007, Alexander Reinholdt" << endl;
cout << endl;
cout << "Usage:" << endl;
cout << " smb4k_mv {user}:{group} {perms} {src} {dest}" << endl;
cout << " smb4k_mv --help" << endl;
cout << " smb4k_mv --version" << endl;
cout << endl;
cout << "Arguments:" << endl;
cout << " {user}\tThe (new) owner of the file" << endl;
cout << endl;
cout << " {group}\tThe (new) group of the file" << endl;
cout << endl;
cout << " {perms}\tThe new permissions of the file" << endl;
cout << endl;
cout << " {src}\t\tThe (full) path of the source file" << endl;
cout << endl;
cout << " {dest}\tThe destination where the file will be moved to" << endl;
cout << endl;
cout << " --help\tDisplay this help screen and exit." << endl;
cout << " --version\tDisplay the version information and exit." << endl;
cout << endl;
}
void version()
{
cout << "Version: " << SMB4K_MV_VERSION << endl;
}
bool find_program( const char *name, char *path )
{
const char *paths[] = { "/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/", "/usr/local/bin/", "/usr/local/sbin/" };
string file = "";
for ( uint i = 0; i < sizeof( paths ) / sizeof( char * ); i++ )
{
string p( paths[i] );
p.append( name );
if ( access( p.c_str(), X_OK ) == 0 )
{
file.assign( p );
break;
}
}
if ( !strcmp( file.c_str(), "" ) )
{
cerr << "smb4k_mv: Could not find " << name << " binary" << endl;
return false;
}
int len = strlen( file.c_str() ) + 1;
(void) strncpy( path, file.c_str(), len );
path[len-1] = '\0';
return true;
}
int main( int argc, char *argv[], char *envp[] )
{
(void) setlocale( LC_ALL, "" );
if ( argc < 2 )
{
info();
exit( EXIT_FAILURE );
}
char *user_group = NULL;
char *permissions = NULL;
char *source = NULL;
char *destination = NULL;
int c;
while ( 1 )
{
int option_index = 0;
static struct option long_options[] =
{
{ "help", 0, 0, 0 },
{ "version", 0, 0, 0 },
{ 0, 0, 0, 0 }
};
c = getopt_long( argc, argv, "", long_options, &option_index );
if ( c == -1 )
{
break;
}
switch ( c )
{
case 0:
{
// Get the length of the option string, create a
// new string and copy the option into it:
int len = strlen( long_options[option_index].name ) + 1;
char opt[len];
opt[0] = '\0';
(void) strncpy( opt, long_options[option_index].name, len );
opt[len-1] = '\0';
// Now check which option has been provided:
if ( !strncmp( opt, "help", len ) )
{
info();
// That's it. Exit here.
exit( EXIT_SUCCESS );
}
else if ( !strncmp( opt, "version", len ) )
{
version();
// That's it. Exit here.
exit( EXIT_SUCCESS );
}
else
{
break;
}
break;
}
case '?':
{
// Abort the program if an unknown option
// is encountered:
exit( EXIT_FAILURE );
}
default:
{
break;
}
}
}
if ( optind < argc )
{
while ( optind < argc )
{
if ( optind == 1 )
{
if ( strchr( argv[optind], ':' ) )
{
int len = strlen( argv[optind] ) + 1;
user_group = new char[len];
user_group[0] = '\0';
(void) strncpy( user_group, argv[optind], len );
user_group[len-1] = '\0';
}
else
{
cerr << "smb4k_mv: First argument must contain a colon" << endl;
exit( EXIT_FAILURE );
}
}
else if ( optind == 2 )
{
int i = 0;
while ( argv[optind][i] )
{
if ( !isdigit( argv[optind][i] ) )
{
cerr << "smb4k_mv: Second argument must only contain digits" << endl;
exit( EXIT_FAILURE );
}
i++;
}
int len = strlen( argv[optind] ) + 1;
permissions = new char[len];
permissions[0] = '\0';
(void) strncpy( permissions, argv[optind], len );
permissions[len-1] = '\0';
}
else if ( optind == 3 )
{
// We only want regular files to be moved:
struct stat file_stat;
if ( lstat( argv[optind], &file_stat ) == -1 )
{
int err = errno;
cerr << "smb4k_mv: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
if ( !S_ISREG( file_stat.st_mode ) ||
S_ISFIFO( file_stat.st_mode ) ||
S_ISLNK( file_stat.st_mode ) )
{
cerr << "smb4k_mv: '" << argv[optind] << "' is not a regular file" << endl;
exit( EXIT_FAILURE );
}
int len = strlen( argv[optind] ) + 1;
source = new char[len];
source[0] = '\0';
(void) strncpy( source, argv[optind], len );
source[len-1] = '\0';
}
else if ( optind == 4 )
{
// Be sure that the destination either does not
// exist or that it is a regular file:
struct stat file_stat;
bool file_exists = true;
if ( lstat( argv[optind], &file_stat ) == -1 )
{
int err = errno;
// If the file does not exist, that's very good
// for our purposes. Do not error out in that case.
if ( err != ENOENT )
{
cerr << "smb4k_mv: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
else
{
file_exists = false;
}
}
if ( file_exists )
{
if ( !S_ISREG( file_stat.st_mode ) ||
S_ISFIFO( file_stat.st_mode ) ||
S_ISLNK( file_stat.st_mode ) )
{
cerr << "smb4k_mv: '" << argv[optind] << "' is not a regular file" << endl;
exit( EXIT_FAILURE );
}
}
int len = strlen( argv[optind] ) + 1;
destination = new char[len];
destination[0] = '\0';
(void) strncpy( destination, argv[optind], len );
destination[len-1] = '\0';
}
else
{
cerr << "smb4k_mv: There are too many arguments" << endl;
exit( EXIT_FAILURE );
}
optind++;
}
}
int i;
// Change owner and group:
char chown_prog[255];
chown_prog[0] = '\0';
if ( !find_program( "chown", chown_prog ) )
{
exit( EXIT_FAILURE );
}
char *chown_argv[] = { chown_prog, user_group, source, NULL };
if ( fork() == 0 )
{
if ( (i = execve( chown_argv[0], chown_argv, envp )) == -1 )
{
int err = errno;
cerr << "smb4k_mv: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
}
else
{
wait( &i );
}
// Apply new permissions:
char chmod_prog[255];
chmod_prog[0] = '\0';
if ( !find_program( "chmod", chmod_prog ) )
{
exit( EXIT_FAILURE );
}
char *chmod_argv[] = { chmod_prog, permissions, source, NULL };
if ( fork() == 0 )
{
if ( (i = execve( chmod_argv[0], chmod_argv, envp )) == -1 )
{
int err = errno;
cerr << "smb4k_mv: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
}
else
{
wait( &i );
}
// Now, finally, move the file:
char mv_prog[255];
mv_prog[0] = '\0';
if ( !find_program( "mv", mv_prog ) )
{
exit( EXIT_FAILURE );
}
char *mv_argv[] = { mv_prog, source, destination, NULL };
if ( fork() == 0 )
{
if ( (i = execve( mv_argv[0], mv_argv, envp )) == -1 )
{
int err = errno;
cerr << "smb4k_mv: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
}
else
{
wait( &i );
}
return EXIT_SUCCESS;
}

@ -0,0 +1,570 @@
/***************************************************************************
smb4k_umount - This is the unmount utility of Smb4K.
-------------------
begin : Sa Sep 25 2004
copyright : (C) 2004-2007 by Alexander Reinholdt
email : dustpuppy@users.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 *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#if !defined(__FreeBSD__) && !defined(__solaris__) && !defined(USE_SOLARIS)
#include <sys/statfs.h>
#elif defined(__solaris__) || defined(USE_SOLARIS)
#include <sys/types.h>
#include <sys/statvfs.h>
#elif defined(__FreeBSD__)
#include <sys/param.h>
#include <sys/mount.h>
#endif
#ifdef __linux__
#include <sys/utsname.h>
#endif
#include <locale.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define SMB4K_UMOUNT_VERSION "0.14"
void info()
{
cout << "This is smb4k_umount (version " << SMB4K_UMOUNT_VERSION << "), the unmount utility of Smb4K" << endl;
cout << "Copyright (C) 2004-2007, Alexander Reinholdt" << endl;
cout << endl;
cout << "Usage:" << endl;
#ifndef __FreeBSD__
cout << " smb4k_umount {mode} {options} {mountpoint}" << endl;
#else
cout << " smb4k_umount {mountpoint}" << endl;
#endif
cout << " smb4k_umount --help" << endl;
cout << " smb4k_umount --version" << endl;
cout << endl;
cout << "Arguments:" << endl;
cout << " {mode}" << endl;
#ifndef __FreeBSD__
cout << " --no-suid\tsmb4k_umount is run in normal user mode, so smbumount or" << endl;
cout << "\t\tumount.cifs is invoked." << endl;
cout << " --suid\tsmb4k_umount is run in super user mode, so umount is invoked." << endl;
cout << " -n\t\tThe same as the '--no-suid' argument." << endl;
cout << " -s\t\tThe same as the '--suid' argument." << endl;
cout << endl;
cout << " {options}" << endl;
cout << " -t <fs>\tThe file system that should be used for unmounting. Only 'smbfs'" << endl;
cout << "\t\tand 'cifs' are supported. All other file systems will result in" << endl;
cout << "\t\tan error. Please note, that this argument is mandatory." << endl;
#endif
#ifdef __linux__
cout << " -l\t\tPerform a lazy unmount. See the manual page of umount for" << endl;
cout << "\t\tmore information. Please note, that this argument is only" << endl;
cout << "\t\trecognized in super user mode, i.e. if '--suid' is supplied," << endl;
cout << "\t\tand that you need kernel version 2.4.11 or later." << endl;
#endif
cout << endl;
cout << " {mountpoint}\tThe path where the share is mounted to." << endl;
cout << endl;
cout << " --help\tDisplay this help screen and exit." << endl;
cout << " --version\tDisplay the version information and exit." << endl;
cout << endl;
}
void version()
{
cout << "Version " << SMB4K_UMOUNT_VERSION << endl;
}
bool find_program( const char *name, char *path )
{
const char *paths[] = { "/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/", "/usr/local/bin/", "/usr/local/sbin/" };
string file = "";
for ( uint i = 0; i < sizeof( paths ) / sizeof( char * ); i++ )
{
string p( paths[i] );
p.append( name );
if ( access( p.c_str(), X_OK ) == 0 )
{
file.assign( p );
break;
}
}
if ( !strcmp( file.c_str(), "" ) )
{
cerr << "smb4k_umount: Could not find " << name << " binary" << endl;
return false;
}
int len = strlen( file.c_str() ) + 1;
strncpy( path, file.c_str(), len );
path[len-1] = '\0';
return true;
}
bool check_filesystem( const char *path, const char *fs )
{
bool ok = false;
#if !defined(__solaris__) && !defined(USE_SOLARIS)
struct statfs filesystem;
#else
struct statvfs filesystem;
#endif
#if !defined(__solaris__) && !defined(USE_SOLARIS) && !defined(__irix__)
if ( statfs( path, &filesystem ) == -1 )
#elif defined(__irix__)
if ( statfs( path, &filesystem, sizeof( filesystem ), 0 ) == -1 )
#else
if ( statvfs( path, &filesystem ) == -1 )
#endif
{
int err_code = errno;
if ( err_code != EIO && err_code != EACCES )
{
// ok is still FALSE
cerr << "smb4k_umount: " << strerror( err_code ) << endl;
}
else
{
ok = true; // Bypass the check below, because it would yield ok == FALSE
// and we want to be able to unmount broken shares as well.
}
return ok;
}
#if !defined(__FreeBSD__) && !defined(__solaris__) && !defined(USE_SOLARIS) && !defined(__irix__)
// First entry is for CIFS, the second for SMBFS.
if ( (uint)filesystem.f_type == 0xFF534D42 && !strncmp( fs, "cifs", strlen( fs )+1 ) )
{
ok = true;
}
else if ( (uint)filesystem.f_type == 0x517B && !strncmp( fs, "smbfs", strlen( fs )+1 ) )
{
ok = true;
}
#elif defined(__FreeBSD__)
if ( !strncmp( filesystem.f_fstypename, fs, strlen( fs ) ) )
{
ok = true;
}
#elif defined(__solaris__) || defined(USE_SOLARIS)
if ( (uint)filesystem.f_basetype == 0xFF534D42 && !strncmp( fs, "cifs", strlen( fs )+1 ) )
{
ok = true;
}
else if ( (uint)filesystem.f_basetype == 0x517B && !strncmp( fs, "smbfs", strlen( fs )+1 ) )
{
ok = true;
}
#elif defined(__irix__)
if ( (uint)filesystem.f_fstyp == 0xFF534D42 && !strncmp( fs, "cifs", strlen( fs )+1 ) )
{
ok = true;
}
else if ( (uint)filesystem.f_basetype == 0x517B && !strncmp( fs, "smbfs", strlen( fs )+1 ) )
{
ok = true;
}
#endif
else
{
// ok is still FALSE.
cerr << "smb4k_umount: Wrong file system specified" << endl;
}
return ok;
}
int main( int argc, char *argv[], char *envp[] )
{
// First of all, set the locale
(void) setlocale( LC_ALL, "" );
if ( argc < 2 )
{
info();
exit( EXIT_FAILURE );
}
int new_argc = argc + 1;
char *new_argv[new_argc];
int index = 0;
char path[255];
path[0] = '\0';
char *mountpoint = NULL;
#ifndef __FreeBSD__
char *filesystem = NULL;
bool normal_user_mode = true;
bool have_user_mode = false;
#ifdef __linux__
bool lazy_unmount = false;
#endif
#endif
// Get the options that were passed:
int c;
while ( 1 )
{
int option_index = 0;
static struct option long_options[] =
{
{ "help", 0, 0, 0 },
{ "version", 0, 0, 0 },
#ifndef __FreeBSD__
{ "suid", 0, 0, 0 },
{ "no-suid", 0, 0, 0 },
#endif
{ 0, 0, 0, 0 }
};
#ifdef __linux__
c = getopt_long( argc, argv, "t:nsl", long_options, &option_index );
#else
#ifndef __FreeBSD__
c = getopt_long( argc, argv, "t:ns", long_options, &option_index );
#else
c = getopt_long( argc, argv, "", long_options, &option_index );
#endif
#endif
if ( c == -1 )
{
break;
}
switch ( c )
{
case 0:
{
int len = strlen( long_options[option_index].name ) + 1;
char opt[len];
opt[0] = '\0';
(void) strncpy( opt, long_options[option_index].name, len );
opt[len-1] = '\0';
if ( !strncmp( opt, "help", len ) )
{
info();
exit( EXIT_SUCCESS );
}
else if ( !strncmp( opt, "version", len ) )
{
version();
exit( EXIT_SUCCESS );
}
#ifndef __FreeBSD__
else if ( !strncmp( opt, "suid", len ) )
{
// Enter super user mode
normal_user_mode = false;
have_user_mode = true;
break;
}
else if ( !strncmp( opt, "no-suid", len ) )
{
// Enter normal user mode
normal_user_mode = true;
have_user_mode = true;
break;
}
#endif
else
{
break;
}
break;
}
#ifndef __FreeBSD__
case 't':
{
// Get the length of the option argument:
int len = strlen( optarg ) + 1;
if ( strncmp( "smbfs", optarg, len) != 0 &&
strncmp( "cifs", optarg, len ) != 0 )
{
cerr << "smb4k_umount: File system " << optarg << " is not supported" << endl;
exit( EXIT_FAILURE );
}
if ( !filesystem )
{
filesystem = new char[len];
filesystem[0] = '\0';
(void) strncpy( filesystem, optarg, len );
filesystem[len-1] = '\0';
}
break;
}
case 's':
{
// Enter super user mode
normal_user_mode = false;
have_user_mode = true;
break;
}
case 'n':
{
// Enter normal user mode
normal_user_mode = true;
have_user_mode = true;
break;
}
#endif
#ifdef __linux__
case 'l':
{
// Initiate a lazy unmount. The umount binary
// will complain, if '-l' is not supported.
lazy_unmount = true;
break;
}
#endif
case '?':
{
// Abort the program if an unknown option
// is encountered:
exit( EXIT_FAILURE );
}
default:
{
break;
}
};
}
#ifndef __FreeBSD__
// Error out if no user mode was specified.
if ( !have_user_mode )
{
cerr << "smb4k_umount: No mode was specified" << endl;
exit( EXIT_FAILURE );
}
// Error out if the user did not specify any file system.
if ( !filesystem )
{
cerr << "smb4k_umount: No file system was specified" << endl;
exit( EXIT_FAILURE );
}
if ( normal_user_mode )
{
int len = strlen( filesystem ) + 1;
if ( !strncmp( "smbfs", filesystem, len ) )
{
if ( !find_program( "smbumount", path ) )
{
exit( EXIT_FAILURE );
}
}
else
{
if ( !find_program( "umount.cifs", path ) )
{
exit( EXIT_FAILURE );
}
}
len = strlen( path ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], path, len );
new_argv[index][len-1] = '\0';
index++;
}
else
{
if ( !find_program( "umount", path ) )
{
exit( EXIT_FAILURE );
}
int len = strlen( path ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], path, len );
new_argv[index][len-1] = '\0';
index++;
len = strlen( "-t" ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], "-t", len );
new_argv[index][len-1] = '\0';
index++;
len = strlen( filesystem ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], filesystem, len );
new_argv[index][len-1] = '\0';
index++;
#ifdef __linux__
// Lazy unmount?
if ( lazy_unmount )
{
len = strlen( "-l" ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], "-l", len );
new_argv[index][len-1] = '\0';
index++;
}
#endif
}
#else
// We do not need to care about the user mode and
// we also need not to check for the file system,
// since there is only one.
if ( !find_program( "umount", path ) )
{
exit( EXIT_FAILURE );
}
int length = strlen( path ) + 1;
new_argv[index] = new char[length];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], path, length );
new_argv[index][length-1] = '\0';
index++;
#endif
// Add the mount point:
if ( optind < argc )
{
while ( optind < argc )
{
if ( !mountpoint )
{
if ( argv[optind][0] != '\057' )
{
cerr << "smb4k_umount: Argument " << optind << " is not a mount point" << endl;
exit( EXIT_FAILURE );
}
#ifndef __FreeBSD__
if ( !check_filesystem( argv[optind], filesystem ) )
#else
if ( !check_filesystem( argv[optind], "smbfs" ) )
#endif
{
// Error message is given by check_filesystem()
exit( EXIT_FAILURE );
}
int len = strlen( argv[optind] ) + 1;
mountpoint = new char[len];
mountpoint[0] = '\0';
(void) strncpy( mountpoint, argv[optind], len );
mountpoint[len-1] = '\0';
optind++;
}
else
{
break;
}
}
}
if ( !mountpoint )
{
cerr << "smb4k_umount: No mount point was specified" << endl;
exit( EXIT_FAILURE );
}
else
{
int len = strlen( mountpoint ) + 1;
new_argv[index] = new char[len];
new_argv[index][0] = '\0';
(void) strncpy( new_argv[index], mountpoint, len );
new_argv[index][len-1] = '\0';
index++;
}
if ( index >= new_argc )
{
cerr << "smb4k_umount: There are too many arguments" << endl;
exit( EXIT_FAILURE );
}
// Terminate new_argv:
new_argv[index] = NULL;
// Execute command:
if ( execve( new_argv[0], new_argv, envp ) == -1 )
{
int err = errno;
cerr << "smb4k_umount: " << strerror( err ) << endl;
exit( EXIT_FAILURE );
}
return EXIT_SUCCESS;
}
Loading…
Cancel
Save