1 /*
2     This file is part of kdepim.
3 
4     Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5 
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10 
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15 
16     You should have received a copy of the GNU Library General Public License
17     along with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19     Boston, MA 02110-1301, USA.
20 */
21 
22 #include "license.h"
23 
24 using namespace KODE;
25 
26 class License::Private
27 {
28   public:
Private()29     Private()
30       : mType(License::NoLicense), mQtException( false )
31     {
32     }
33 
34     Type mType;
35     bool mQtException;
36 };
37 
License()38 License::License()
39   : d( new Private )
40 {
41 }
42 
License(const License & other)43 License::License( const License &other )
44   : d( new Private )
45 {
46   *d = *other.d;
47 }
48 
License(Type type)49 License::License( Type type )
50   : d( new Private )
51 {
52   d->mType = type;
53 }
54 
~License()55 License::~License()
56 {
57   delete d;
58 }
59 
operator =(const License & other)60 License& License::operator=( const License &other )
61 {
62   if ( this == &other )
63     return *this;
64 
65   *d = *other.d;
66 
67   return *this;
68 }
69 
setQtException(bool v)70 void License::setQtException( bool v )
71 {
72   d->mQtException = v;
73 }
74 
text() const75 QString License::text() const
76 {
77   QString txt;
78 
79   switch ( d->mType ) {
80     case GPL:
81       txt +=
82             "This program is free software; you can redistribute it and/or modify\n"
83             "it under the terms of the GNU General Public License as published by\n"
84             "the Free Software Foundation; either version 2 of the License, or\n"
85             "(at your option) any later version.\n"
86             "\n"
87             "This program is distributed in the hope that it will be useful,\n"
88             "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
89             "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
90             "GNU General Public License for more details.\n"
91             "\n"
92             "You should have received a copy of the GNU General Public License\n"
93             "along with this program; if not, write to the Free Software\n"
94             "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n" "USA.\n";
95 
96       if ( d->mQtException ) {
97         txt += '\n';
98         txt +=
99             "As a special exception, permission is given to link this program\n"
100             "with any edition of Qt, and distribute the resulting executable,\n"
101             "without including the source code for Qt in the source distribution.\n";
102       }
103       break;
104     case LGPL:
105       txt +=
106             "This library is free software; you can redistribute it and/or\n"
107             "modify it under the terms of the GNU Library General Public\n"
108             "License as published by the Free Software Foundation; either\n"
109             "version 2 of the License, or (at your option) any later version.\n"
110             "\n"
111             "This library is distributed in the hope that it will be useful,\n"
112             "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
113             "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
114             "Library General Public License for more details.\n"
115             "\n"
116             "You should have received a copy of the GNU Library General Public License\n"
117             "along with this library; see the file COPYING.LIB.  If not, write to\n"
118             "the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n"
119             "Boston, MA 02110-1301, USA.\n";
120       break;
121     case BSD:
122       txt +=
123             "Permission is hereby granted, free of charge, to any person obtaining\n"
124             "a copy of this software and associated documentation files (the\n"
125             "\"Software\"), to deal in the Software without restriction, including\n"
126             "without limitation the rights to use, copy, modify, merge, publish,\n"
127             "distribute, sublicense, and/or sell copies of the Software, and to\n"
128             "permit persons to whom the Software is furnished to do so, subject to\n"
129             "the following conditions:\n"
130             "\n"
131             "The above copyright notice and this permission notice shall be\n"
132             "included in all copies or substantial portions of the Software.\n"
133             "\n"
134             "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n"
135             "EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n"
136             "MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\n"
137             "IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n"
138             "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n"
139             "ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n"
140             "OTHER DEALINGS IN THE SOFTWARE.";
141       break;
142     case GeneratedNoRestriction:
143       txt +=
144             "You may use and relicense this generated file without restriction.";
145     default:
146       break;
147   }
148 
149   return txt;
150 }
151