-rw-r--r-- | kabc/stdaddressbook.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index a14ae20..43d9fde 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -43,32 +43,49 @@ bool StdAddressBook::mAutomaticSave = false; | |||
43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
44 | 44 | ||
45 | QString StdAddressBook::fileName() | 45 | QString StdAddressBook::fileName() |
46 | { | 46 | { |
47 | return locateLocal( "data", "kabc/std.vcf" ); | 47 | return locateLocal( "data", "kabc/std.vcf" ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | StdAddressBook *StdAddressBook::selfNoLoad() | ||
60 | { | ||
61 | |||
62 | if ( !mSelf ) | ||
63 | { | ||
64 | QString appdir = StdAddressBook::setTempAppDir(); | ||
65 | // US im am not sure why I have to use the other format here?? | ||
66 | #ifdef KAB_EMBEDDED | ||
67 | mSelf = addressBookDeleter.setObject( new StdAddressBook ( QString() ) ); | ||
68 | #else //KAB_EMBEDDED | ||
69 | addressBookDeleter.setObject( mSelf, new StdAddressBook( QString() ) ); | ||
70 | #endif //KAB_EMBEDDED | ||
71 | KStandardDirs::setAppDir( appdir ); | ||
72 | } | ||
73 | |||
74 | return mSelf; | ||
75 | } | ||
59 | 76 | ||
60 | StdAddressBook *StdAddressBook::self() | 77 | StdAddressBook *StdAddressBook::self() |
61 | { | 78 | { |
62 | 79 | ||
63 | if ( !mSelf ) | 80 | if ( !mSelf ) |
64 | { | 81 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 82 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | // US im am not sure why I have to use the other format here?? | 83 | // US im am not sure why I have to use the other format here?? |
67 | #ifdef KAB_EMBEDDED | 84 | #ifdef KAB_EMBEDDED |
68 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 85 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
69 | #else //KAB_EMBEDDED | 86 | #else //KAB_EMBEDDED |
70 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 87 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
71 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
72 | KStandardDirs::setAppDir( appdir ); | 89 | KStandardDirs::setAppDir( appdir ); |
73 | } | 90 | } |
74 | 91 | ||
@@ -95,46 +112,50 @@ QString StdAddressBook::setTempAppDir() | |||
95 | } | 112 | } |
96 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 113 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
97 | { | 114 | { |
98 | 115 | ||
99 | if ( !mSelf ) | 116 | if ( !mSelf ) |
100 | { | 117 | { |
101 | QString appdir =StdAddressBook::setTempAppDir(); | 118 | QString appdir =StdAddressBook::setTempAppDir(); |
102 | #ifdef KAB_EMBEDDED | 119 | #ifdef KAB_EMBEDDED |
103 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 120 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
104 | #else //KAB_EMBEDDED | 121 | #else //KAB_EMBEDDED |
105 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 122 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
106 | #endif //KAB_EMBEDDED | 123 | #endif //KAB_EMBEDDED |
107 | KStandardDirs::setAppDir( appdir ); | 124 | KStandardDirs::setAppDir( appdir ); |
108 | } | 125 | } |
109 | return mSelf; | 126 | return mSelf; |
110 | } | 127 | } |
128 | StdAddressBook::StdAddressBook( QString ) | ||
129 | : AddressBook( "kabcrc" ) | ||
130 | { | ||
131 | |||
132 | } | ||
111 | 133 | ||
112 | StdAddressBook::StdAddressBook() | 134 | StdAddressBook::StdAddressBook() |
113 | : AddressBook( "kabcrc" ) | 135 | : AddressBook( "kabcrc" ) |
114 | { | 136 | { |
115 | 137 | ||
116 | //init( false ); | 138 | init( false ); |
117 | } | 139 | } |
118 | 140 | ||
119 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 141 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
120 | : AddressBook( "kabcrc" ) | 142 | : AddressBook( "kabcrc" ) |
121 | { | 143 | { |
122 | 144 | ||
123 | if ( onlyFastResources ) | 145 | init( onlyFastResources ); |
124 | init( onlyFastResources ); | ||
125 | } | 146 | } |
126 | 147 | ||
127 | StdAddressBook::~StdAddressBook() | 148 | StdAddressBook::~StdAddressBook() |
128 | { | 149 | { |
129 | if ( mAutomaticSave ) | 150 | if ( mAutomaticSave ) |
130 | save(); | 151 | save(); |
131 | } | 152 | } |
132 | 153 | ||
133 | void StdAddressBook::init( bool ) | 154 | void StdAddressBook::init( bool ) |
134 | { | 155 | { |
135 | KRES::Manager<Resource> *manager = resourceManager(); | 156 | KRES::Manager<Resource> *manager = resourceManager(); |
136 | KRES::Manager<Resource>::ActiveIterator it; | 157 | KRES::Manager<Resource>::ActiveIterator it; |
137 | 158 | ||
138 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 159 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
139 | (*it)->setAddressBook( this ); | 160 | (*it)->setAddressBook( this ); |
140 | if ( !(*it)->open() ) | 161 | if ( !(*it)->open() ) |