summaryrefslogtreecommitdiffstats
path: root/smb4k/core/smb4kbookmark.h
blob: 536862c864ce296f0742087f66a7a5fafe9c9341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/***************************************************************************
    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

// TQt includes
#include <tqstring.h>

#include <kdemacros.h>

// forward declarations
class Smb4KShareItem;

/**
 * This class is a container for a set bookmark on a samba share
 */

class KDE_EXPORT 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 TQString &hostname,
                   const TQString &sharename,
                   const TQString &workgroup,
                   const TQString &ip,
                   const TQString &type,
                   const TQString &label = TQString() );

    /**
     * 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 TQString &ip,
                   const TQString &label = TQString() );

    /**
     * The empty constructor.
     */
    Smb4KBookmark() {}

    /**
     * The destructor.
     */
    ~Smb4KBookmark();

    /**
     * This function returns the share name.
     *
     * @returns         The share name
     */
    const TQString &share() const { return m_share; };

    /**
     * This function returns the workgroup/domain the share is located in.
     *
     * @returns         The workgroup
     */
    const TQString &workgroup() const { return m_workgroup; }

    /**
     * This function returns the IP address of the host that carries the
     * share.
     *
     * @returns         The IP address
     */
    const TQString &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 TQString &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 TQString &name );

    /**
     * This function returns the bookmark name.
     *
     * @returns         The name of the bookmark
     */
    const TQString &bookmark() const { return m_bookmark; }

    /**
     * This function returns the host name.
     *
     * @returns         The name of the host
     */
    const TQString &host() const { return m_host; }

    /**
     * This function sets the IP address.
     *
     * @param ip        The IP address
     */
    void setIP( const TQString &ip );

    /**
     * Return the alternative bookmark label.
     *
     * @returns the label.
     */
    const TQString &label() const { return m_label; }

    /**
     * Sets the alternative bookmark label.
     *
     * @param text      The new text for the label
     */
    void setLabel( const TQString &text );

  private:
    /**
     * The host name.
     */
    TQString m_host;

    /**
     * The share name.
     */
    TQString m_share;

    /**
     * The workgroup
     */
    TQString m_workgroup;

    /**
     * The IP address
     */
    TQString m_ip;

    /**
     * The type of the share;
     */
    TQString m_type;

    /**
     * The bookmark string.
     */
    TQString m_bookmark;

    /**
     * The alternative label
     */
    TQString 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 TQString &ip );
};

#endif