-rw-r--r-- | kde2file/abdump/main.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp index d452ee9..1ee64f5 100644 --- a/kde2file/abdump/main.cpp +++ b/kde2file/abdump/main.cpp | |||
@@ -123,32 +123,33 @@ int main( int argc, char *argv[] ) | |||
123 | //Addressee::List aList;//parseVCards( const QString& vcard ); | 123 | //Addressee::List aList;//parseVCards( const QString& vcard ); |
124 | KABC::Addressee::List list; | 124 | KABC::Addressee::List list; |
125 | int added = 0, changedC = 0, deleted = 0; | 125 | int added = 0, changedC = 0, deleted = 0; |
126 | QFile file( fileName ); | 126 | QFile file( fileName ); |
127 | if ( file.open( IO_ReadOnly ) ) { | 127 | if ( file.open( IO_ReadOnly ) ) { |
128 | QTextStream t( &file ); // use a text stream | 128 | QTextStream t( &file ); // use a text stream |
129 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 129 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
130 | QString data; | 130 | QString data; |
131 | data = t.read(); | 131 | data = t.read(); |
132 | file.close(); | 132 | file.close(); |
133 | KABC::VCardConverter converter; | 133 | KABC::VCardConverter converter; |
134 | list = converter.parseVCards( data ); | 134 | list = converter.parseVCards( data ); |
135 | qDebug("kdeABdump::file has %d entries", list.count()); | 135 | qDebug("kdeABdump::file has %d entries", list.count()); |
136 | 136 | ||
137 | KABC::Addressee::List::Iterator it; | 137 | KABC::Addressee::List::Iterator it; |
138 | for ( it = list.begin();it != list.end();++it) { | 138 | for ( it = list.begin();it != list.end();++it) { |
139 | (*it).setChanged( true ); | ||
139 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); | 140 | bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); |
140 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 141 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
141 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); | 142 | //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); |
142 | if ( changed ) { | 143 | if ( changed ) { |
143 | //qDebug("changed Addressee found! "); | 144 | //qDebug("changed Addressee found! "); |
144 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 145 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
145 | if ( ! std.isEmpty() ) | 146 | if ( ! std.isEmpty() ) |
146 | (*it).setResource(std.resource()); | 147 | (*it).setResource(std.resource()); |
147 | standardAddressBook->insertAddressee( (*it) ); | 148 | standardAddressBook->insertAddressee( (*it) ); |
148 | ++changedC; | 149 | ++changedC; |
149 | } else { | 150 | } else { |
150 | //maybe added? | 151 | //maybe added? |
151 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); | 152 | KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); |
152 | if ( std.isEmpty() ) { | 153 | if ( std.isEmpty() ) { |
153 | standardAddressBook->insertAddressee( (*it) ); | 154 | standardAddressBook->insertAddressee( (*it) ); |
154 | ++added; | 155 | ++added; |
@@ -173,21 +174,22 @@ int main( int argc, char *argv[] ) | |||
173 | ++deleted; | 174 | ++deleted; |
174 | } else { | 175 | } else { |
175 | ++itA; | 176 | ++itA; |
176 | } | 177 | } |
177 | } | 178 | } |
178 | 179 | ||
179 | //standardAddressBook->saveAll(); | 180 | //standardAddressBook->saveAll(); |
180 | standardAddressBook->setAutomaticSave( true ); | 181 | standardAddressBook->setAutomaticSave( true ); |
181 | qDebug("************************************* "); | 182 | qDebug("************************************* "); |
182 | qDebug("*************kdeABdump*************** "); | 183 | qDebug("*************kdeABdump*************** "); |
183 | qDebug("************************************* "); | 184 | qDebug("************************************* "); |
184 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); | 185 | qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1()); |
185 | } else | 186 | } else |
186 | qDebug("error open file "); | 187 | qDebug("error open file "); |
187 | } | 188 | } |
188 | 189 | ||
189 | KABC::StdAddressBook::close(); | 190 | delete standardAddressBook; |
190 | 191 | //KABC::StdAddressBook::close(); | |
192 | //StdAddressBook::mSelf = 0; | ||
191 | qDebug("ente "); | 193 | qDebug("ente "); |
192 | return 0; | 194 | return 0; |
193 | } | 195 | } |