-rw-r--r-- | kabc/formatfactory.cpp | 2 | ||||
-rw-r--r-- | kabc/formatplugin.h | 5 | ||||
-rw-r--r-- | kabc/kabcE.pro | 2 | ||||
-rw-r--r-- | kabc/stdaddressbook.cpp | 6 |
4 files changed, 9 insertions, 6 deletions
diff --git a/kabc/formatfactory.cpp b/kabc/formatfactory.cpp index f107ebf..f2f03c6 100644 --- a/kabc/formatfactory.cpp +++ b/kabc/formatfactory.cpp | |||
@@ -1,182 +1,180 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <ksimpleconfig.h> | 23 | #include <ksimpleconfig.h> |
24 | #include <kstandarddirs.h> | 24 | #include <kstandarddirs.h> |
25 | #include <kstaticdeleter.h> | 25 | #include <kstaticdeleter.h> |
26 | 26 | ||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | #include "vcardformatplugin.h" | 30 | #include "vcardformatplugin.h" |
31 | 31 | ||
32 | #include "formatfactory.h" | 32 | #include "formatfactory.h" |
33 | 33 | ||
34 | using namespace KABC; | 34 | using namespace KABC; |
35 | 35 | ||
36 | FormatFactory *FormatFactory::mSelf = 0; | 36 | FormatFactory *FormatFactory::mSelf = 0; |
37 | static KStaticDeleter<FormatFactory> factoryDeleter; | 37 | static KStaticDeleter<FormatFactory> factoryDeleter; |
38 | 38 | ||
39 | FormatFactory *FormatFactory::self() | 39 | FormatFactory *FormatFactory::self() |
40 | { | 40 | { |
41 | kdDebug(5700) << "FormatFactory::self()" << endl; | ||
42 | |||
43 | if ( !mSelf ) { | 41 | if ( !mSelf ) { |
44 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); | 42 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); |
45 | mSelf = factoryDeleter.setObject( new FormatFactory ); | 43 | mSelf = factoryDeleter.setObject( new FormatFactory ); |
46 | } | 44 | } |
47 | return mSelf; | 45 | return mSelf; |
48 | } | 46 | } |
49 | 47 | ||
50 | FormatFactory::FormatFactory() | 48 | FormatFactory::FormatFactory() |
51 | { | 49 | { |
52 | mFormatList.setAutoDelete( true ); | 50 | mFormatList.setAutoDelete( true ); |
53 | 51 | ||
54 | // dummy entry for default format | 52 | // dummy entry for default format |
55 | FormatInfo *info = new FormatInfo; | 53 | FormatInfo *info = new FormatInfo; |
56 | info->library = "<NoLibrary>"; | 54 | info->library = "<NoLibrary>"; |
57 | info->nameLabel = i18n( "vCard" ); | 55 | info->nameLabel = i18n( "vCard" ); |
58 | info->descriptionLabel = i18n( "vCard Format" ); | 56 | info->descriptionLabel = i18n( "vCard Format" ); |
59 | mFormatList.insert( "vcard", info ); | 57 | mFormatList.insert( "vcard", info ); |
60 | 58 | ||
61 | /*US lets enter all resources directly instead of using teh desktopfiles. | 59 | /*US lets enter all resources directly instead of using teh desktopfiles. |
62 | 60 | ||
63 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); | 61 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); |
64 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) | 62 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) |
65 | { | 63 | { |
66 | //US KSimpleConfig config( *it, true ); | 64 | //US KSimpleConfig config( *it, true ); |
67 | KConfig config( *it ); | 65 | KConfig config( *it ); |
68 | 66 | ||
69 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) | 67 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) |
70 | continue; | 68 | continue; |
71 | 69 | ||
72 | info = new FormatInfo; | 70 | info = new FormatInfo; |
73 | 71 | ||
74 | config.setGroup( "Plugin" ); | 72 | config.setGroup( "Plugin" ); |
75 | QString type = config.readEntry( "Type" ); | 73 | QString type = config.readEntry( "Type" ); |
76 | info->library = config.readEntry( "X-KDE-Library" ); | 74 | info->library = config.readEntry( "X-KDE-Library" ); |
77 | 75 | ||
78 | config.setGroup( "Misc" ); | 76 | config.setGroup( "Misc" ); |
79 | info->nameLabel = config.readEntry( "Name" ); | 77 | info->nameLabel = config.readEntry( "Name" ); |
80 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); | 78 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); |
81 | 79 | ||
82 | mFormatList.insert( type, info ); | 80 | mFormatList.insert( type, info ); |
83 | } | 81 | } |
84 | */ | 82 | */ |
85 | //US we already have vcard as default format. | 83 | //US we already have vcard as default format. |
86 | info = new FormatInfo; | 84 | info = new FormatInfo; |
87 | info->library = i18n("microkabcformat_binary"); | 85 | info->library = i18n("microkabcformat_binary"); |
88 | info->nameLabel = i18n( "Binary" ); | 86 | info->nameLabel = i18n( "Binary" ); |
89 | info->descriptionLabel = i18n( "No description available." ); | 87 | info->descriptionLabel = i18n( "No description available." ); |
90 | mFormatList.insert( "binary", info ); | 88 | mFormatList.insert( "binary", info ); |
91 | 89 | ||
92 | } | 90 | } |
93 | 91 | ||
94 | FormatFactory::~FormatFactory() | 92 | FormatFactory::~FormatFactory() |
95 | { | 93 | { |
96 | mFormatList.clear(); | 94 | mFormatList.clear(); |
97 | } | 95 | } |
98 | 96 | ||
99 | QStringList FormatFactory::formats() | 97 | QStringList FormatFactory::formats() |
100 | { | 98 | { |
101 | QStringList retval; | 99 | QStringList retval; |
102 | 100 | ||
103 | // make sure 'vcard' is the first entry | 101 | // make sure 'vcard' is the first entry |
104 | retval << "vcard"; | 102 | retval << "vcard"; |
105 | 103 | ||
106 | QDictIterator<FormatInfo> it( mFormatList ); | 104 | QDictIterator<FormatInfo> it( mFormatList ); |
107 | for ( ; it.current(); ++it ) | 105 | for ( ; it.current(); ++it ) |
108 | if ( it.currentKey() != "vcard" ) | 106 | if ( it.currentKey() != "vcard" ) |
109 | retval << it.currentKey(); | 107 | retval << it.currentKey(); |
110 | 108 | ||
111 | return retval; | 109 | return retval; |
112 | } | 110 | } |
113 | 111 | ||
114 | FormatInfo *FormatFactory::info( const QString &type ) | 112 | FormatInfo *FormatFactory::info( const QString &type ) |
115 | { | 113 | { |
116 | if ( type.isEmpty() ) | 114 | if ( type.isEmpty() ) |
117 | return 0; | 115 | return 0; |
118 | else | 116 | else |
119 | return mFormatList[ type ]; | 117 | return mFormatList[ type ]; |
120 | } | 118 | } |
121 | 119 | ||
122 | FormatPlugin *FormatFactory::format( const QString& type ) | 120 | FormatPlugin *FormatFactory::format( const QString& type ) |
123 | { | 121 | { |
124 | FormatPlugin *format = 0; | 122 | FormatPlugin *format = 0; |
125 | 123 | ||
126 | if ( type.isEmpty() ) | 124 | if ( type.isEmpty() ) |
127 | return 0; | 125 | return 0; |
128 | 126 | ||
129 | if ( type == "vcard" ) { | 127 | if ( type == "vcard" ) { |
130 | format = new VCardFormatPlugin; | 128 | format = new VCardFormatPlugin; |
131 | format->setType( type ); | 129 | format->setType( type ); |
132 | format->setNameLabel( i18n( "vCard" ) ); | 130 | format->setNameLabel( i18n( "vCard" ) ); |
133 | format->setDescriptionLabel( i18n( "vCard Format" ) ); | 131 | format->setDescriptionLabel( i18n( "vCard Format" ) ); |
134 | return format; | 132 | return format; |
135 | } | 133 | } |
136 | 134 | ||
137 | FormatInfo *fi = mFormatList[ type ]; | 135 | FormatInfo *fi = mFormatList[ type ]; |
138 | if (!fi) | 136 | if (!fi) |
139 | return 0; | 137 | return 0; |
140 | QString libName = fi->library; | 138 | QString libName = fi->library; |
141 | #ifndef DESKTOP_VERSION | 139 | #ifndef DESKTOP_VERSION |
142 | KLibrary *library = openLibrary( libName ); | 140 | KLibrary *library = openLibrary( libName ); |
143 | if ( !library ) | 141 | if ( !library ) |
144 | return 0; | 142 | return 0; |
145 | 143 | ||
146 | void *format_func = library->symbol( "format"); | 144 | void *format_func = library->symbol( "format"); |
147 | 145 | ||
148 | if ( format_func ) { | 146 | if ( format_func ) { |
149 | format = ((FormatPlugin* (*)())format_func)(); | 147 | format = ((FormatPlugin* (*)())format_func)(); |
150 | format->setType( type ); | 148 | format->setType( type ); |
151 | format->setNameLabel( fi->nameLabel ); | 149 | format->setNameLabel( fi->nameLabel ); |
152 | format->setDescriptionLabel( fi->descriptionLabel ); | 150 | format->setDescriptionLabel( fi->descriptionLabel ); |
153 | } else { | 151 | } else { |
154 | kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl; | 152 | kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl; |
155 | return 0; | 153 | return 0; |
156 | } | 154 | } |
157 | #endif | 155 | #endif |
158 | return format; | 156 | return format; |
159 | } | 157 | } |
160 | 158 | ||
161 | #ifndef DESKTOP_VERSION | 159 | #ifndef DESKTOP_VERSION |
162 | KLibrary *FormatFactory::openLibrary( const QString& libName ) | 160 | KLibrary *FormatFactory::openLibrary( const QString& libName ) |
163 | { | 161 | { |
164 | KLibrary *library = 0; | 162 | KLibrary *library = 0; |
165 | 163 | ||
166 | QString path = KLibLoader::findLibrary( QFile::encodeName( libName ) ); | 164 | QString path = KLibLoader::findLibrary( QFile::encodeName( libName ) ); |
167 | 165 | ||
168 | if ( path.isEmpty() ) { | 166 | if ( path.isEmpty() ) { |
169 | kdDebug( 5700 ) << "No format plugin library was found!" << endl; | 167 | kdDebug( 5700 ) << "No format plugin library was found!" << endl; |
170 | return 0; | 168 | return 0; |
171 | } | 169 | } |
172 | 170 | ||
173 | library = KLibLoader::self()->library( QFile::encodeName( path ) ); | 171 | library = KLibLoader::self()->library( QFile::encodeName( path ) ); |
174 | 172 | ||
175 | if ( !library ) { | 173 | if ( !library ) { |
176 | kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl; | 174 | kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl; |
177 | return 0; | 175 | return 0; |
178 | } | 176 | } |
179 | 177 | ||
180 | return library; | 178 | return library; |
181 | } | 179 | } |
182 | #endif | 180 | #endif |
diff --git a/kabc/formatplugin.h b/kabc/formatplugin.h index d784daf..40a6922 100644 --- a/kabc/formatplugin.h +++ b/kabc/formatplugin.h | |||
@@ -1,81 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_FORMATPLUGIN_H | 28 | #ifndef KABC_FORMATPLUGIN_H |
29 | #define KABC_FORMATPLUGIN_H | 29 | #define KABC_FORMATPLUGIN_H |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | 32 | ||
33 | //US #include "plugin.h" | 33 | #include "plugin.h" |
34 | #include "resource.h" | 34 | #include "resource.h" |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | 37 | ||
38 | class AddressBook; | 38 | class AddressBook; |
39 | class Addressee; | 39 | class Addressee; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * @short Base class for address book formats. | 42 | * @short Base class for address book formats. |
43 | * | 43 | * |
44 | * This class provides an abstract interface for ResourceFile and | 44 | * This class provides an abstract interface for ResourceFile and |
45 | * ResourceDir formats. | 45 | * ResourceDir formats. |
46 | * | 46 | * |
47 | * @internal | 47 | * @internal |
48 | */ | 48 | */ |
49 | //US class FormatPlugin : public Plugin | 49 | class FormatPlugin : public Plugin |
50 | class FormatPlugin | ||
51 | { | 50 | { |
52 | public: | 51 | public: |
53 | 52 | ||
54 | /** | 53 | /** |
55 | * Load single addressee from file. | 54 | * Load single addressee from file. |
56 | */ | 55 | */ |
57 | virtual bool load( Addressee &, QFile *file ) = 0; | 56 | virtual bool load( Addressee &, QFile *file ) = 0; |
58 | 57 | ||
59 | /** | 58 | /** |
60 | * Load whole addressbook from file. | 59 | * Load whole addressbook from file. |
61 | */ | 60 | */ |
62 | virtual bool loadAll( AddressBook *, Resource *, QFile *file ) = 0; | 61 | virtual bool loadAll( AddressBook *, Resource *, QFile *file ) = 0; |
63 | 62 | ||
64 | /** | 63 | /** |
65 | * Save a single Addressee to file. | 64 | * Save a single Addressee to file. |
66 | */ | 65 | */ |
67 | virtual void save( const Addressee &, QFile *file ) = 0; | 66 | virtual void save( const Addressee &, QFile *file ) = 0; |
68 | 67 | ||
69 | /** | 68 | /** |
70 | * Save whole addressbook to file. | 69 | * Save whole addressbook to file. |
71 | */ | 70 | */ |
72 | virtual void saveAll( AddressBook *, Resource *, QFile *file ) = 0; | 71 | virtual void saveAll( AddressBook *, Resource *, QFile *file ) = 0; |
73 | 72 | ||
74 | /** | 73 | /** |
75 | * Checks if given file contains the right format | 74 | * Checks if given file contains the right format |
76 | */ | 75 | */ |
77 | virtual bool checkFormat( QFile *file ) const = 0; | 76 | virtual bool checkFormat( QFile *file ) const = 0; |
78 | }; | 77 | }; |
79 | 78 | ||
80 | } | 79 | } |
81 | #endif | 80 | #endif |
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro index 6a3bbf1..840afb9 100644 --- a/kabc/kabcE.pro +++ b/kabc/kabcE.pro | |||
@@ -1,188 +1,188 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc | 3 | TARGET = microkabc |
4 | 4 | ||
5 | 5 | ||
6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat | 6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat $(QPEDIR)/include |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde | 10 | LIBS += -lmicrokde |
11 | #LIBS += -lldap | 11 | #LIBS += -lldap |
12 | LIBS += -L$(QPEDIR)/lib | 12 | LIBS += -L$(QPEDIR)/lib |
13 | DEFINES += KAB_EMBEDDED | 13 | DEFINES += KAB_EMBEDDED |
14 | 14 | ||
15 | INTERFACES = \ | 15 | INTERFACES = \ |
16 | 16 | ||
17 | HEADERS = \ | 17 | HEADERS = \ |
18 | address.h \ | 18 | address.h \ |
19 | addressbook.h \ | 19 | addressbook.h \ |
20 | addressee.h \ | 20 | addressee.h \ |
21 | addresseedialog.h \ | 21 | addresseedialog.h \ |
22 | addresseelist.h \ | 22 | addresseelist.h \ |
23 | agent.h \ | 23 | agent.h \ |
24 | distributionlist.h \ | 24 | distributionlist.h \ |
25 | distributionlistdialog.h \ | 25 | distributionlistdialog.h \ |
26 | distributionlisteditor.h \ | 26 | distributionlisteditor.h \ |
27 | field.h \ | 27 | field.h \ |
28 | formatfactory.h \ | 28 | formatfactory.h \ |
29 | formatplugin.h \ | 29 | formatplugin.h \ |
30 | geo.h \ | 30 | geo.h \ |
31 | key.h \ | 31 | key.h \ |
32 | phonenumber.h \ | 32 | phonenumber.h \ |
33 | picture.h \ | 33 | picture.h \ |
34 | plugin.h \ | 34 | plugin.h \ |
35 | resource.h \ | 35 | resource.h \ |
36 | secrecy.h \ | 36 | secrecy.h \ |
37 | sound.h \ | 37 | sound.h \ |
38 | stdaddressbook.h \ | 38 | stdaddressbook.h \ |
39 | timezone.h \ | 39 | timezone.h \ |
40 | vcardconverter.h \ | 40 | vcardconverter.h \ |
41 | vcard21parser.h \ | 41 | vcard21parser.h \ |
42 | vcardformatimpl.h \ | 42 | vcardformatimpl.h \ |
43 | vcardformatplugin.h \ | 43 | vcardformatplugin.h \ |
44 | vcardparser/vcardline.h \ | 44 | vcardparser/vcardline.h \ |
45 | vcardparser/vcard.h \ | 45 | vcardparser/vcard.h \ |
46 | vcardparser/vcardtool.h \ | 46 | vcardparser/vcardtool.h \ |
47 | vcardparser/vcardparser.h \ | 47 | vcardparser/vcardparser.h \ |
48 | vcard/include/VCardAdrParam.h \ | 48 | vcard/include/VCardAdrParam.h \ |
49 | vcard/include/VCardAdrValue.h \ | 49 | vcard/include/VCardAdrValue.h \ |
50 | vcard/include/VCardAgentParam.h \ | 50 | vcard/include/VCardAgentParam.h \ |
51 | vcard/include/VCardContentLine.h \ | 51 | vcard/include/VCardContentLine.h \ |
52 | vcard/include/VCardDateParam.h \ | 52 | vcard/include/VCardDateParam.h \ |
53 | vcard/include/VCardDateValue.h \ | 53 | vcard/include/VCardDateValue.h \ |
54 | vcard/include/VCardEmailParam.h \ | 54 | vcard/include/VCardEmailParam.h \ |
55 | vcard/include/VCardGeoValue.h \ | 55 | vcard/include/VCardGeoValue.h \ |
56 | vcard/include/VCardGroup.h \ | 56 | vcard/include/VCardGroup.h \ |
57 | vcard/include/VCardImageParam.h \ | 57 | vcard/include/VCardImageParam.h \ |
58 | vcard/include/VCardImageValue.h \ | 58 | vcard/include/VCardImageValue.h \ |
59 | vcard/include/VCardLangValue.h \ | 59 | vcard/include/VCardLangValue.h \ |
60 | vcard/include/VCardNValue.h \ | 60 | vcard/include/VCardNValue.h \ |
61 | vcard/include/VCardParam.h \ | 61 | vcard/include/VCardParam.h \ |
62 | vcard/include/VCardPhoneNumberValue.h \ | 62 | vcard/include/VCardPhoneNumberValue.h \ |
63 | vcard/include/VCardSourceParam.h \ | 63 | vcard/include/VCardSourceParam.h \ |
64 | vcard/include/VCardTelParam.h \ | 64 | vcard/include/VCardTelParam.h \ |
65 | vcard/include/VCardTextParam.h \ | 65 | vcard/include/VCardTextParam.h \ |
66 | vcard/include/VCardTextNSParam.h \ | 66 | vcard/include/VCardTextNSParam.h \ |
67 | vcard/include/VCardTextValue.h \ | 67 | vcard/include/VCardTextValue.h \ |
68 | vcard/include/VCardTextBinParam.h \ | 68 | vcard/include/VCardTextBinParam.h \ |
69 | vcard/include/VCardURIValue.h \ | 69 | vcard/include/VCardURIValue.h \ |
70 | vcard/include/VCardVCard.h \ | 70 | vcard/include/VCardVCard.h \ |
71 | vcard/include/VCardEntity.h \ | 71 | vcard/include/VCardEntity.h \ |
72 | vcard/include/VCardValue.h \ | 72 | vcard/include/VCardValue.h \ |
73 | vcard/include/VCardSoundValue.h \ | 73 | vcard/include/VCardSoundValue.h \ |
74 | vcard/include/VCardAgentValue.h \ | 74 | vcard/include/VCardAgentValue.h \ |
75 | vcard/include/VCardTelValue.h \ | 75 | vcard/include/VCardTelValue.h \ |
76 | vcard/include/VCardTextBinValue.h \ | 76 | vcard/include/VCardTextBinValue.h \ |
77 | vcard/include/VCardOrgValue.h \ | 77 | vcard/include/VCardOrgValue.h \ |
78 | vcard/include/VCardUTCValue.h \ | 78 | vcard/include/VCardUTCValue.h \ |
79 | vcard/include/VCardClassValue.h \ | 79 | vcard/include/VCardClassValue.h \ |
80 | vcard/include/VCardFloatValue.h \ | 80 | vcard/include/VCardFloatValue.h \ |
81 | vcard/include/VCardTextListValue.h \ | 81 | vcard/include/VCardTextListValue.h \ |
82 | vcard/include/generated/AdrParam-generated.h \ | 82 | vcard/include/generated/AdrParam-generated.h \ |
83 | vcard/include/generated/AdrValue-generated.h \ | 83 | vcard/include/generated/AdrValue-generated.h \ |
84 | vcard/include/generated/AgentParam-generated.h \ | 84 | vcard/include/generated/AgentParam-generated.h \ |
85 | vcard/include/generated/ContentLine-generated.h \ | 85 | vcard/include/generated/ContentLine-generated.h \ |
86 | vcard/include/generated/DateParam-generated.h \ | 86 | vcard/include/generated/DateParam-generated.h \ |
87 | vcard/include/generated/DateValue-generated.h \ | 87 | vcard/include/generated/DateValue-generated.h \ |
88 | vcard/include/generated/EmailParam-generated.h \ | 88 | vcard/include/generated/EmailParam-generated.h \ |
89 | vcard/include/generated/GeoValue-generated.h \ | 89 | vcard/include/generated/GeoValue-generated.h \ |
90 | vcard/include/generated/Group-generated.h \ | 90 | vcard/include/generated/Group-generated.h \ |
91 | vcard/include/generated/ImageParam-generated.h \ | 91 | vcard/include/generated/ImageParam-generated.h \ |
92 | vcard/include/generated/ImageValue-generated.h \ | 92 | vcard/include/generated/ImageValue-generated.h \ |
93 | vcard/include/generated/LangValue-generated.h \ | 93 | vcard/include/generated/LangValue-generated.h \ |
94 | vcard/include/generated/NValue-generated.h \ | 94 | vcard/include/generated/NValue-generated.h \ |
95 | vcard/include/generated/Param-generated.h \ | 95 | vcard/include/generated/Param-generated.h \ |
96 | vcard/include/generated/PhoneNumberValue-generated.h \ | 96 | vcard/include/generated/PhoneNumberValue-generated.h \ |
97 | vcard/include/generated/SourceParam-generated.h \ | 97 | vcard/include/generated/SourceParam-generated.h \ |
98 | vcard/include/generated/TelParam-generated.h \ | 98 | vcard/include/generated/TelParam-generated.h \ |
99 | vcard/include/generated/TextParam-generated.h \ | 99 | vcard/include/generated/TextParam-generated.h \ |
100 | vcard/include/generated/TextNSParam-generated.h \ | 100 | vcard/include/generated/TextNSParam-generated.h \ |
101 | vcard/include/generated/TextValue-generated.h \ | 101 | vcard/include/generated/TextValue-generated.h \ |
102 | vcard/include/generated/TextBinParam-generated.h \ | 102 | vcard/include/generated/TextBinParam-generated.h \ |
103 | vcard/include/generated/URIValue-generated.h \ | 103 | vcard/include/generated/URIValue-generated.h \ |
104 | vcard/include/generated/VCard-generated.h \ | 104 | vcard/include/generated/VCard-generated.h \ |
105 | vcard/include/generated/VCardEntity-generated.h \ | 105 | vcard/include/generated/VCardEntity-generated.h \ |
106 | vcard/include/generated/Value-generated.h \ | 106 | vcard/include/generated/Value-generated.h \ |
107 | vcard/include/generated/SoundValue-generated.h \ | 107 | vcard/include/generated/SoundValue-generated.h \ |
108 | vcard/include/generated/AgentValue-generated.h \ | 108 | vcard/include/generated/AgentValue-generated.h \ |
109 | vcard/include/generated/TelValue-generated.h \ | 109 | vcard/include/generated/TelValue-generated.h \ |
110 | vcard/include/generated/TextBinValue-generated.h \ | 110 | vcard/include/generated/TextBinValue-generated.h \ |
111 | vcard/include/generated/OrgValue-generated.h \ | 111 | vcard/include/generated/OrgValue-generated.h \ |
112 | vcard/include/generated/UTCValue-generated.h \ | 112 | vcard/include/generated/UTCValue-generated.h \ |
113 | vcard/include/generated/ClassValue-generated.h \ | 113 | vcard/include/generated/ClassValue-generated.h \ |
114 | vcard/include/generated/FloatValue-generated.h \ | 114 | vcard/include/generated/FloatValue-generated.h \ |
115 | vcard/include/generated/TextListValue-generated.h | 115 | vcard/include/generated/TextListValue-generated.h |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | 119 | ||
120 | SOURCES = \ | 120 | SOURCES = \ |
121 | address.cpp \ | 121 | address.cpp \ |
122 | addressbook.cpp \ | 122 | addressbook.cpp \ |
123 | addressee.cpp \ | 123 | addressee.cpp \ |
124 | addresseedialog.cpp \ | 124 | addresseedialog.cpp \ |
125 | addresseelist.cpp \ | 125 | addresseelist.cpp \ |
126 | agent.cpp \ | 126 | agent.cpp \ |
127 | distributionlist.cpp \ | 127 | distributionlist.cpp \ |
128 | distributionlistdialog.cpp \ | 128 | distributionlistdialog.cpp \ |
129 | distributionlisteditor.cpp \ | 129 | distributionlisteditor.cpp \ |
130 | field.cpp \ | 130 | field.cpp \ |
131 | formatfactory.cpp \ | 131 | formatfactory.cpp \ |
132 | geo.cpp \ | 132 | geo.cpp \ |
133 | key.cpp \ | 133 | key.cpp \ |
134 | phonenumber.cpp \ | 134 | phonenumber.cpp \ |
135 | picture.cpp \ | 135 | picture.cpp \ |
136 | plugin.cpp \ | 136 | plugin.cpp \ |
137 | resource.cpp \ | 137 | resource.cpp \ |
138 | secrecy.cpp \ | 138 | secrecy.cpp \ |
139 | sound.cpp \ | 139 | sound.cpp \ |
140 | stdaddressbook.cpp \ | 140 | stdaddressbook.cpp \ |
141 | timezone.cpp \ | 141 | timezone.cpp \ |
142 | vcardconverter.cpp \ | 142 | vcardconverter.cpp \ |
143 | vcard21parser.cpp \ | 143 | vcard21parser.cpp \ |
144 | vcardformatimpl.cpp \ | 144 | vcardformatimpl.cpp \ |
145 | vcardformatplugin.cpp \ | 145 | vcardformatplugin.cpp \ |
146 | vcardparser/vcardline.cpp \ | 146 | vcardparser/vcardline.cpp \ |
147 | vcardparser/vcard.cpp \ | 147 | vcardparser/vcard.cpp \ |
148 | vcardparser/vcardtool.cpp \ | 148 | vcardparser/vcardtool.cpp \ |
149 | vcardparser/vcardparser.cpp \ | 149 | vcardparser/vcardparser.cpp \ |
150 | vcard/AdrParam.cpp \ | 150 | vcard/AdrParam.cpp \ |
151 | vcard/AdrValue.cpp \ | 151 | vcard/AdrValue.cpp \ |
152 | vcard/AgentParam.cpp \ | 152 | vcard/AgentParam.cpp \ |
153 | vcard/ContentLine.cpp \ | 153 | vcard/ContentLine.cpp \ |
154 | vcard/DateParam.cpp \ | 154 | vcard/DateParam.cpp \ |
155 | vcard/DateValue.cpp \ | 155 | vcard/DateValue.cpp \ |
156 | vcard/EmailParam.cpp \ | 156 | vcard/EmailParam.cpp \ |
157 | vcard/Entity.cpp \ | 157 | vcard/Entity.cpp \ |
158 | vcard/Enum.cpp \ | 158 | vcard/Enum.cpp \ |
159 | vcard/GeoValue.cpp \ | 159 | vcard/GeoValue.cpp \ |
160 | vcard/ImageParam.cpp \ | 160 | vcard/ImageParam.cpp \ |
161 | vcard/ImageValue.cpp \ | 161 | vcard/ImageValue.cpp \ |
162 | vcard/LangValue.cpp \ | 162 | vcard/LangValue.cpp \ |
163 | vcard/NValue.cpp \ | 163 | vcard/NValue.cpp \ |
164 | vcard/Param.cpp \ | 164 | vcard/Param.cpp \ |
165 | vcard/PhoneNumberValue.cpp \ | 165 | vcard/PhoneNumberValue.cpp \ |
166 | vcard/RToken.cpp \ | 166 | vcard/RToken.cpp \ |
167 | vcard/SourceParam.cpp \ | 167 | vcard/SourceParam.cpp \ |
168 | vcard/TelParam.cpp \ | 168 | vcard/TelParam.cpp \ |
169 | vcard/TextParam.cpp \ | 169 | vcard/TextParam.cpp \ |
170 | vcard/TextValue.cpp \ | 170 | vcard/TextValue.cpp \ |
171 | vcard/TextBinParam.cpp \ | 171 | vcard/TextBinParam.cpp \ |
172 | vcard/URIValue.cpp \ | 172 | vcard/URIValue.cpp \ |
173 | vcard/VCardv.cpp \ | 173 | vcard/VCardv.cpp \ |
174 | vcard/VCardEntity.cpp \ | 174 | vcard/VCardEntity.cpp \ |
175 | vcard/Value.cpp \ | 175 | vcard/Value.cpp \ |
176 | vcard/SoundValue.cpp \ | 176 | vcard/SoundValue.cpp \ |
177 | vcard/AgentValue.cpp \ | 177 | vcard/AgentValue.cpp \ |
178 | vcard/TelValue.cpp \ | 178 | vcard/TelValue.cpp \ |
179 | vcard/TextBinValue.cpp \ | 179 | vcard/TextBinValue.cpp \ |
180 | vcard/OrgValue.cpp \ | 180 | vcard/OrgValue.cpp \ |
181 | vcard/UTCValue.cpp \ | 181 | vcard/UTCValue.cpp \ |
182 | vcard/ClassValue.cpp \ | 182 | vcard/ClassValue.cpp \ |
183 | vcard/FloatValue.cpp \ | 183 | vcard/FloatValue.cpp \ |
184 | vcard/TextListValue.cpp | 184 | vcard/TextListValue.cpp |
185 | 185 | ||
186 | 186 | ||
187 | # plugins/ldap/resourceldap.cpp \ | 187 | # plugins/ldap/resourceldap.cpp \ |
188 | # plugins/ldap/resourceldapconfig.cpp \ | 188 | # plugins/ldap/resourceldapconfig.cpp \ |
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index 8faaaef..144a9dc 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -1,233 +1,239 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | 30 | ||
31 | #include <kapplication.h> | 31 | #include <kapplication.h> |
32 | #include <kcrash.h> | 32 | #include <kcrash.h> |
33 | #include <ksimpleconfig.h> | 33 | #include <ksimpleconfig.h> |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | ||
37 | #include <qpe/global.h> | ||
38 | #else | ||
39 | #include <qdir.h> | ||
40 | #endif | ||
41 | |||
36 | #include "resource.h" | 42 | #include "resource.h" |
37 | #include <kresources/manager.h> | 43 | #include <kresources/manager.h> |
38 | #include <kdebug.h> | 44 | #include <kdebug.h> |
39 | #include <klocale.h> | 45 | #include <klocale.h> |
40 | #include <kstaticdeleter.h> | 46 | #include <kstaticdeleter.h> |
41 | #include <kstandarddirs.h> | 47 | #include <kstandarddirs.h> |
42 | 48 | ||
43 | #include "stdaddressbook.h" | 49 | #include "stdaddressbook.h" |
44 | 50 | ||
45 | using namespace KABC; | 51 | using namespace KABC; |
46 | 52 | ||
47 | StdAddressBook *StdAddressBook::mSelf = 0; | 53 | StdAddressBook *StdAddressBook::mSelf = 0; |
48 | bool StdAddressBook::mAutomaticSave = true; | 54 | bool StdAddressBook::mAutomaticSave = true; |
49 | 55 | ||
50 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 56 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
51 | 57 | ||
52 | QString StdAddressBook::fileName() | 58 | QString StdAddressBook::fileName() |
53 | { | 59 | { |
54 | return locateLocal( "data", "kabc/std.vcf" ); | 60 | return locateLocal( "data", "kabc/std.vcf" ); |
55 | } | 61 | } |
56 | 62 | ||
57 | QString StdAddressBook::directoryName() | 63 | QString StdAddressBook::directoryName() |
58 | { | 64 | { |
59 | return locateLocal( "data", "kabc/stdvcf" ); | 65 | return locateLocal( "data", "kabc/stdvcf" ); |
60 | } | 66 | } |
61 | 67 | ||
62 | void StdAddressBook::handleCrash() | 68 | void StdAddressBook::handleCrash() |
63 | { | 69 | { |
64 | StdAddressBook::self()->cleanUp(); | 70 | StdAddressBook::self()->cleanUp(); |
65 | } | 71 | } |
66 | 72 | ||
67 | StdAddressBook *StdAddressBook::self() | 73 | StdAddressBook *StdAddressBook::self() |
68 | { | 74 | { |
69 | 75 | ||
70 | if ( !mSelf ) | 76 | if ( !mSelf ) |
71 | { | 77 | { |
72 | QString appdir = StdAddressBook::setTempAppDir(); | 78 | QString appdir = StdAddressBook::setTempAppDir(); |
73 | 79 | ||
74 | kdDebug(5700) << "StdAddressBook::self()" << endl; | 80 | kdDebug(5700) << "StdAddressBook::self()" << endl; |
75 | // US im am not sure why I have to use the other format here?? | 81 | // US im am not sure why I have to use the other format here?? |
76 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
77 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 83 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
78 | #else //KAB_EMBEDDED | 84 | #else //KAB_EMBEDDED |
79 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 85 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
80 | #endif //KAB_EMBEDDED | 86 | #endif //KAB_EMBEDDED |
81 | KStandardDirs::setAppDir( appdir ); | 87 | KStandardDirs::setAppDir( appdir ); |
82 | } | 88 | } |
83 | 89 | ||
84 | return mSelf; | 90 | return mSelf; |
85 | } | 91 | } |
86 | 92 | ||
87 | QString StdAddressBook::setTempAppDir() | 93 | QString StdAddressBook::setTempAppDir() |
88 | { | 94 | { |
89 | QString appDIR = KStandardDirs::appDir(); | 95 | QString appDIR = KStandardDirs::appDir(); |
90 | #ifdef DESKTOP_VERSION | 96 | #ifdef DESKTOP_VERSION |
91 | QString appdir = QDir::homeDirPath(); | 97 | QString appdir = QDir::homeDirPath(); |
92 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 98 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
93 | appdir += "kaddressbook/"; | 99 | appdir += "kaddressbook/"; |
94 | else | 100 | else |
95 | appdir += "/kaddressbook/"; | 101 | appdir += "/kaddressbook/"; |
96 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 102 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
97 | #else | 103 | #else |
98 | KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) ); | 104 | KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) ); |
99 | #endif | 105 | #endif |
100 | 106 | ||
101 | return appDIR; | 107 | return appDIR; |
102 | } | 108 | } |
103 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 109 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
104 | { | 110 | { |
105 | 111 | ||
106 | if ( !mSelf ) | 112 | if ( !mSelf ) |
107 | { | 113 | { |
108 | QString appdir =StdAddressBook::setTempAppDir(); | 114 | QString appdir =StdAddressBook::setTempAppDir(); |
109 | #ifdef KAB_EMBEDDED | 115 | #ifdef KAB_EMBEDDED |
110 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 116 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
111 | #else //KAB_EMBEDDED | 117 | #else //KAB_EMBEDDED |
112 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 118 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
113 | #endif //KAB_EMBEDDED | 119 | #endif //KAB_EMBEDDED |
114 | KStandardDirs::setAppDir( appdir ); | 120 | KStandardDirs::setAppDir( appdir ); |
115 | } | 121 | } |
116 | return mSelf; | 122 | return mSelf; |
117 | } | 123 | } |
118 | 124 | ||
119 | StdAddressBook::StdAddressBook() | 125 | StdAddressBook::StdAddressBook() |
120 | //US : AddressBook( "kabcrc" ) | 126 | //US : AddressBook( "kabcrc" ) |
121 | : AddressBook( locateLocal( "config", "kabcrc") ) | 127 | : AddressBook( locateLocal( "config", "kabcrc") ) |
122 | { | 128 | { |
123 | 129 | ||
124 | init( false ); | 130 | init( false ); |
125 | } | 131 | } |
126 | 132 | ||
127 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 133 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
128 | //US : AddressBook( "kabcrc" ) | 134 | //US : AddressBook( "kabcrc" ) |
129 | : AddressBook( locateLocal( "config", "kabcrc") ) | 135 | : AddressBook( locateLocal( "config", "kabcrc") ) |
130 | { | 136 | { |
131 | 137 | ||
132 | init( onlyFastResources ); | 138 | init( onlyFastResources ); |
133 | } | 139 | } |
134 | 140 | ||
135 | StdAddressBook::~StdAddressBook() | 141 | StdAddressBook::~StdAddressBook() |
136 | { | 142 | { |
137 | if ( mAutomaticSave ) | 143 | if ( mAutomaticSave ) |
138 | save(); | 144 | save(); |
139 | } | 145 | } |
140 | 146 | ||
141 | void StdAddressBook::init( bool ) | 147 | void StdAddressBook::init( bool ) |
142 | { | 148 | { |
143 | KRES::Manager<Resource> *manager = resourceManager(); | 149 | KRES::Manager<Resource> *manager = resourceManager(); |
144 | KRES::Manager<Resource>::ActiveIterator it; | 150 | KRES::Manager<Resource>::ActiveIterator it; |
145 | 151 | ||
146 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 152 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
147 | (*it)->setAddressBook( this ); | 153 | (*it)->setAddressBook( this ); |
148 | if ( !(*it)->open() ) | 154 | if ( !(*it)->open() ) |
149 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 155 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
150 | } | 156 | } |
151 | 157 | ||
152 | Resource *res = standardResource(); | 158 | Resource *res = standardResource(); |
153 | if ( !res ) { | 159 | if ( !res ) { |
154 | res = manager->createResource( "file" ); | 160 | res = manager->createResource( "file" ); |
155 | if ( res ) | 161 | if ( res ) |
156 | { | 162 | { |
157 | addResource( res ); | 163 | addResource( res ); |
158 | } | 164 | } |
159 | else | 165 | else |
160 | kdDebug(5700) << "No resource available!!!" << endl; | 166 | kdDebug(5700) << "No resource available!!!" << endl; |
161 | } | 167 | } |
162 | 168 | ||
163 | setStandardResource( res ); | 169 | setStandardResource( res ); |
164 | manager->writeConfig(); | 170 | manager->writeConfig(); |
165 | 171 | ||
166 | load(); | 172 | load(); |
167 | } | 173 | } |
168 | 174 | ||
169 | bool StdAddressBook::save() | 175 | bool StdAddressBook::save() |
170 | { | 176 | { |
171 | kdDebug(5700) << "StdAddressBook::save()" << endl; | 177 | kdDebug(5700) << "StdAddressBook::save()" << endl; |
172 | 178 | ||
173 | bool ok = true; | 179 | bool ok = true; |
174 | AddressBook *ab = self(); | 180 | AddressBook *ab = self(); |
175 | 181 | ||
176 | ab->deleteRemovedAddressees(); | 182 | ab->deleteRemovedAddressees(); |
177 | 183 | ||
178 | KRES::Manager<Resource>::ActiveIterator it; | 184 | KRES::Manager<Resource>::ActiveIterator it; |
179 | KRES::Manager<Resource> *manager = ab->resourceManager(); | 185 | KRES::Manager<Resource> *manager = ab->resourceManager(); |
180 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 186 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
181 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 187 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
182 | Ticket *ticket = ab->requestSaveTicket( *it ); | 188 | Ticket *ticket = ab->requestSaveTicket( *it ); |
183 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 189 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
184 | if ( !ticket ) { | 190 | if ( !ticket ) { |
185 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 191 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
186 | .arg( (*it)->resourceName() ) ); | 192 | .arg( (*it)->resourceName() ) ); |
187 | return false; | 193 | return false; |
188 | } | 194 | } |
189 | 195 | ||
190 | if ( !ab->save( ticket ) ) | 196 | if ( !ab->save( ticket ) ) |
191 | ok = false; | 197 | ok = false; |
192 | } | 198 | } |
193 | } | 199 | } |
194 | 200 | ||
195 | return ok; | 201 | return ok; |
196 | } | 202 | } |
197 | 203 | ||
198 | void StdAddressBook::close() | 204 | void StdAddressBook::close() |
199 | { | 205 | { |
200 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 206 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
201 | //US addressBookDeleter.destructObject(); | 207 | //US addressBookDeleter.destructObject(); |
202 | addressBookDeleter.setObject(0); | 208 | addressBookDeleter.setObject(0); |
203 | 209 | ||
204 | } | 210 | } |
205 | 211 | ||
206 | void StdAddressBook::setAutomaticSave( bool enable ) | 212 | void StdAddressBook::setAutomaticSave( bool enable ) |
207 | { | 213 | { |
208 | mAutomaticSave = enable; | 214 | mAutomaticSave = enable; |
209 | } | 215 | } |
210 | 216 | ||
211 | bool StdAddressBook::automaticSave() | 217 | bool StdAddressBook::automaticSave() |
212 | { | 218 | { |
213 | return mAutomaticSave; | 219 | return mAutomaticSave; |
214 | } | 220 | } |
215 | 221 | ||
216 | // should get const for 4.X | 222 | // should get const for 4.X |
217 | Addressee StdAddressBook::whoAmI() | 223 | Addressee StdAddressBook::whoAmI() |
218 | { | 224 | { |
219 | //US KConfig config( "kabcrc" ); | 225 | //US KConfig config( "kabcrc" ); |
220 | KConfig config( locateLocal("config", "kabcrc") ); | 226 | KConfig config( locateLocal("config", "kabcrc") ); |
221 | config.setGroup( "General" ); | 227 | config.setGroup( "General" ); |
222 | 228 | ||
223 | return findByUid( config.readEntry( "WhoAmI" ) ); | 229 | return findByUid( config.readEntry( "WhoAmI" ) ); |
224 | } | 230 | } |
225 | 231 | ||
226 | void StdAddressBook::setWhoAmI( const Addressee &addr ) | 232 | void StdAddressBook::setWhoAmI( const Addressee &addr ) |
227 | { | 233 | { |
228 | //US KConfig config( "kabcrc" ); | 234 | //US KConfig config( "kabcrc" ); |
229 | KConfig config( locateLocal("config", "kabcrc") ); | 235 | KConfig config( locateLocal("config", "kabcrc") ); |
230 | config.setGroup( "General" ); | 236 | config.setGroup( "General" ); |
231 | 237 | ||
232 | config.writeEntry( "WhoAmI", addr.uid() ); | 238 | config.writeEntry( "WhoAmI", addr.uid() ); |
233 | } | 239 | } |