-rw-r--r-- | kabc/stdaddressbook.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index 8faaaef..144a9dc 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -1,131 +1,137 @@ | |||
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 | ||