summaryrefslogtreecommitdiffabout
path: root/kabc/stdaddressbook.cpp
authorzautrix <zautrix>2004-07-07 03:28:52 (UTC)
committer zautrix <zautrix>2004-07-07 03:28:52 (UTC)
commit816db8f76a1fd8b5cc586dfd5ebf8d6298221801 (patch) (unidiff)
treee418207a02e60c0807e75731a19c44a58d0fb896 /kabc/stdaddressbook.cpp
parent3db5c4e190d1031f2471516f8a52114f06d1a3eb (diff)
downloadkdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.zip
kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.gz
kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.bz2
Changed some strings. Removed some kdebug
Diffstat (limited to 'kabc/stdaddressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 075f12f..1e00cc6 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -59,170 +59,170 @@ void StdAddressBook::handleCrash()
59 59
60StdAddressBook *StdAddressBook::self() 60StdAddressBook *StdAddressBook::self()
61{ 61{
62 62
63 if ( !mSelf ) 63 if ( !mSelf )
64 { 64 {
65 QString appdir = StdAddressBook::setTempAppDir(); 65 QString appdir = StdAddressBook::setTempAppDir();
66 66
67 kdDebug(5700) << "StdAddressBook::self()" << endl; 67 kdDebug(5700) << "StdAddressBook::self()" << endl;
68// US im am not sure why I have to use the other format here?? 68// US im am not sure why I have to use the other format here??
69#ifdef KAB_EMBEDDED 69#ifdef KAB_EMBEDDED
70 mSelf = addressBookDeleter.setObject( new StdAddressBook ); 70 mSelf = addressBookDeleter.setObject( new StdAddressBook );
71#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
72 addressBookDeleter.setObject( mSelf, new StdAddressBook ); 72 addressBookDeleter.setObject( mSelf, new StdAddressBook );
73#endif //KAB_EMBEDDED 73#endif //KAB_EMBEDDED
74 KStandardDirs::setAppDir( appdir ); 74 KStandardDirs::setAppDir( appdir );
75 } 75 }
76 76
77 return mSelf; 77 return mSelf;
78} 78}
79 79
80QString StdAddressBook::setTempAppDir() 80QString StdAddressBook::setTempAppDir()
81{ 81{
82 QString appDIR = KStandardDirs::appDir(); 82 QString appDIR = KStandardDirs::appDir();
83#ifdef DESKTOP_VERSION 83#ifdef DESKTOP_VERSION
84 QString appdir = QDir::homeDirPath(); 84 QString appdir = QDir::homeDirPath();
85 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) 85 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
86 appdir += "kaddressbook/"; 86 appdir += "kaddressbook/";
87 else 87 else
88 appdir += "/kaddressbook/"; 88 appdir += "/kaddressbook/";
89 KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); 89 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
90#else 90#else
91 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; 91 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
92 92
93 KStandardDirs::setAppDir( appdir ); 93 KStandardDirs::setAppDir( appdir );
94#endif 94#endif
95 95
96 return appDIR; 96 return appDIR;
97} 97}
98StdAddressBook *StdAddressBook::self( bool onlyFastResources ) 98StdAddressBook *StdAddressBook::self( bool onlyFastResources )
99{ 99{
100 100
101 if ( !mSelf ) 101 if ( !mSelf )
102 { 102 {
103 QString appdir =StdAddressBook::setTempAppDir(); 103 QString appdir =StdAddressBook::setTempAppDir();
104#ifdef KAB_EMBEDDED 104#ifdef KAB_EMBEDDED
105 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); 105 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
106#else //KAB_EMBEDDED 106#else //KAB_EMBEDDED
107 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); 107 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
108#endif //KAB_EMBEDDED 108#endif //KAB_EMBEDDED
109 KStandardDirs::setAppDir( appdir ); 109 KStandardDirs::setAppDir( appdir );
110 } 110 }
111 return mSelf; 111 return mSelf;
112} 112}
113 113
114StdAddressBook::StdAddressBook() 114StdAddressBook::StdAddressBook()
115//US : AddressBook( "kabcrc" ) 115//US : AddressBook( "kabcrc" )
116 : AddressBook( locateLocal( "config", "kabcrc") ) 116 : AddressBook( locateLocal( "config", "kabcrc") )
117{ 117{
118 118
119 init( false ); 119 init( false );
120} 120}
121 121
122StdAddressBook::StdAddressBook( bool onlyFastResources ) 122StdAddressBook::StdAddressBook( bool onlyFastResources )
123//US : AddressBook( "kabcrc" ) 123//US : AddressBook( "kabcrc" )
124 : AddressBook( locateLocal( "config", "kabcrc") ) 124 : AddressBook( locateLocal( "config", "kabcrc") )
125{ 125{
126 126
127 init( onlyFastResources ); 127 init( onlyFastResources );
128} 128}
129 129
130StdAddressBook::~StdAddressBook() 130StdAddressBook::~StdAddressBook()
131{ 131{
132 if ( mAutomaticSave ) 132 if ( mAutomaticSave )
133 save(); 133 save();
134} 134}
135 135
136void StdAddressBook::init( bool ) 136void StdAddressBook::init( bool )
137{ 137{
138 KRES::Manager<Resource> *manager = resourceManager(); 138 KRES::Manager<Resource> *manager = resourceManager();
139 KRES::Manager<Resource>::ActiveIterator it; 139 KRES::Manager<Resource>::ActiveIterator it;
140 140
141 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 141 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
142 (*it)->setAddressBook( this ); 142 (*it)->setAddressBook( this );
143 if ( !(*it)->open() ) 143 if ( !(*it)->open() )
144 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 144 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
145 } 145 }
146 146
147 Resource *res = standardResource(); 147 Resource *res = standardResource();
148 if ( !res ) { 148 if ( !res ) {
149 res = manager->createResource( "file" ); 149 res = manager->createResource( "file" );
150 if ( res ) 150 if ( res )
151 { 151 {
152 addResource( res ); 152 addResource( res );
153 } 153 }
154 else 154 else
155 kdDebug(5700) << "No resource available!!!" << endl; 155 qDebug(" No resource available!!!");
156 } 156 }
157 157
158 setStandardResource( res ); 158 setStandardResource( res );
159 manager->writeConfig(); 159 manager->writeConfig();
160 160
161 load(); 161 load();
162} 162}
163 163
164bool StdAddressBook::save() 164bool StdAddressBook::save()
165{ 165{
166 kdDebug(5700) << "StdAddressBook::save()" << endl; 166 kdDebug(5700) << "StdAddressBook::save()" << endl;
167 167
168 bool ok = true; 168 bool ok = true;
169 AddressBook *ab = self(); 169 AddressBook *ab = self();
170 170
171 ab->deleteRemovedAddressees(); 171 ab->deleteRemovedAddressees();
172 172
173 KRES::Manager<Resource>::ActiveIterator it; 173 KRES::Manager<Resource>::ActiveIterator it;
174 KRES::Manager<Resource> *manager = ab->resourceManager(); 174 KRES::Manager<Resource> *manager = ab->resourceManager();
175 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 175 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
176 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 176 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
177 Ticket *ticket = ab->requestSaveTicket( *it ); 177 Ticket *ticket = ab->requestSaveTicket( *it );
178// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 178// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
179 if ( !ticket ) { 179 if ( !ticket ) {
180 ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) 180 ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
181 .arg( (*it)->resourceName() ) ); 181 .arg( (*it)->resourceName() ) );
182 return false; 182 return false;
183 } 183 }
184 184
185 if ( !ab->save( ticket ) ) 185 if ( !ab->save( ticket ) )
186 ok = false; 186 ok = false;
187 } 187 }
188 } 188 }
189 189
190 return ok; 190 return ok;
191} 191}
192 192
193void StdAddressBook::close() 193void StdAddressBook::close()
194{ 194{
195//US destructObject is not defined on my system???. Is setObject(0) the same ??? 195//US destructObject is not defined on my system???. Is setObject(0) the same ???
196//US addressBookDeleter.destructObject(); 196//US addressBookDeleter.destructObject();
197 addressBookDeleter.setObject(0); 197 addressBookDeleter.setObject(0);
198 198
199} 199}
200 200
201void StdAddressBook::setAutomaticSave( bool enable ) 201void StdAddressBook::setAutomaticSave( bool enable )
202{ 202{
203 mAutomaticSave = enable; 203 mAutomaticSave = enable;
204} 204}
205 205
206bool StdAddressBook::automaticSave() 206bool StdAddressBook::automaticSave()
207{ 207{
208 return mAutomaticSave; 208 return mAutomaticSave;
209} 209}
210 210
211// should get const for 4.X 211// should get const for 4.X
212Addressee StdAddressBook::whoAmI() 212Addressee StdAddressBook::whoAmI()
213{ 213{
214//US KConfig config( "kabcrc" ); 214//US KConfig config( "kabcrc" );
215 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
216 config.setGroup( "General" ); 216 config.setGroup( "General" );
217 217
218 return findByUid( config.readEntry( "WhoAmI" ) ); 218 return findByUid( config.readEntry( "WhoAmI" ) );
219} 219}
220 220
221void StdAddressBook::setWhoAmI( const Addressee &addr ) 221void StdAddressBook::setWhoAmI( const Addressee &addr )
222{ 222{
223//US KConfig config( "kabcrc" ); 223//US KConfig config( "kabcrc" );
224 KConfig config( locateLocal("config", "kabcrc") ); 224 KConfig config( locateLocal("config", "kabcrc") );
225 config.setGroup( "General" ); 225 config.setGroup( "General" );
226 226
227 config.writeEntry( "WhoAmI", addr.uid() ); 227 config.writeEntry( "WhoAmI", addr.uid() );
228} 228}