-rw-r--r-- | kabc/vcardformatimpl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index c31af46..b9fe6ff 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -78,97 +78,97 @@ bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFi | |||
78 | 78 | ||
79 | VCardEntity e( data ); | 79 | VCardEntity e( data ); |
80 | 80 | ||
81 | VCardListIterator it( e.cardList() ); | 81 | VCardListIterator it( e.cardList() ); |
82 | 82 | ||
83 | for (; it.current(); ++it) { | 83 | for (; it.current(); ++it) { |
84 | //US VCard v(*it.current()); | 84 | //US VCard v(*it.current()); |
85 | Addressee addressee; | 85 | Addressee addressee; |
86 | //US loadAddressee( addressee, v ); | 86 | //US loadAddressee( addressee, v ); |
87 | loadAddressee( addressee, it.current() ); | 87 | loadAddressee( addressee, it.current() ); |
88 | addressee.setResource( resource ); | 88 | addressee.setResource( resource ); |
89 | addressBook->insertAddressee( addressee ); | 89 | addressBook->insertAddressee( addressee ); |
90 | if (debug == true) | 90 | if (debug == true) |
91 | { | 91 | { |
92 | printf("address %s loaded successfully\n", addressee.formattedName().latin1()); | 92 | printf("address %s loaded successfully\n", addressee.formattedName().latin1()); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | return true; | 96 | return true; |
97 | } | 97 | } |
98 | 98 | ||
99 | void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) | 99 | void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) |
100 | { | 100 | { |
101 | VCardEntity vcards; | 101 | VCardEntity vcards; |
102 | VCardList vcardlist; | 102 | VCardList vcardlist; |
103 | vcardlist.setAutoDelete( true ); | 103 | vcardlist.setAutoDelete( true ); |
104 | 104 | ||
105 | VCard *v = new VCard; | 105 | VCard *v = new VCard; |
106 | 106 | ||
107 | saveAddressee( addressee, v, false ); | 107 | saveAddressee( addressee, v, false ); |
108 | 108 | ||
109 | vcardlist.append( v ); | 109 | vcardlist.append( v ); |
110 | vcards.setCardList( vcardlist ); | 110 | vcards.setCardList( vcardlist ); |
111 | 111 | ||
112 | QCString vcardData = vcards.asString(); | 112 | QCString vcardData = vcards.asString(); |
113 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 113 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) | 116 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) |
117 | { | 117 | { |
118 | VCardEntity vcards; | 118 | VCardEntity vcards; |
119 | VCardList vcardlist; | 119 | VCardList vcardlist; |
120 | vcardlist.setAutoDelete( true ); | 120 | vcardlist.setAutoDelete( true ); |
121 | 121 | ||
122 | AddressBook::Iterator it; | 122 | AddressBook::Iterator it; |
123 | for ( it = ab->begin(); it != ab->end(); ++it ) { | 123 | for ( it = ab->begin(); it != ab->end(); ++it ) { |
124 | if ( (*it).resource() == resource ) { | 124 | if ( (*it).resource() == resource ) { |
125 | VCard *v = new VCard; | 125 | VCard *v = new VCard; |
126 | saveAddressee( (*it), v, false ); | 126 | saveAddressee( (*it), v, true ); |
127 | (*it).setChanged( false ); | 127 | (*it).setChanged( false ); |
128 | vcardlist.append( v ); | 128 | vcardlist.append( v ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | vcards.setCardList( vcardlist ); | 132 | vcards.setCardList( vcardlist ); |
133 | 133 | ||
134 | QCString vcardData = vcards.asString(); | 134 | QCString vcardData = vcards.asString(); |
135 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 135 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | 138 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) |
139 | { | 139 | { |
140 | QPtrList<ContentLine> contentLines = v->contentLineList(); | 140 | QPtrList<ContentLine> contentLines = v->contentLineList(); |
141 | ContentLine *cl; | 141 | ContentLine *cl; |
142 | 142 | ||
143 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 143 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
144 | QCString n = cl->name(); | 144 | QCString n = cl->name(); |
145 | if ( n.left( 2 ) == "X-" ) { | 145 | if ( n.left( 2 ) == "X-" ) { |
146 | n = n.mid( 2 ); | 146 | n = n.mid( 2 ); |
147 | int posDash = n.find( "-" ); | 147 | int posDash = n.find( "-" ); |
148 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), | 148 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), |
149 | QString::fromUtf8( n.mid( posDash + 1 ) ), | 149 | QString::fromUtf8( n.mid( posDash + 1 ) ), |
150 | QString::fromUtf8( cl->value()->asString() ) ); | 150 | QString::fromUtf8( cl->value()->asString() ) ); |
151 | continue; | 151 | continue; |
152 | } | 152 | } |
153 | 153 | ||
154 | EntityType type = cl->entityType(); | 154 | EntityType type = cl->entityType(); |
155 | switch( type ) { | 155 | switch( type ) { |
156 | 156 | ||
157 | case EntityUID: | 157 | case EntityUID: |
158 | addressee.setUid( readTextValue( cl ) ); | 158 | addressee.setUid( readTextValue( cl ) ); |
159 | break; | 159 | break; |
160 | 160 | ||
161 | case EntityEmail: | 161 | case EntityEmail: |
162 | addressee.insertEmail( readTextValue( cl ) ); | 162 | addressee.insertEmail( readTextValue( cl ) ); |
163 | break; | 163 | break; |
164 | 164 | ||
165 | case EntityName: | 165 | case EntityName: |
166 | addressee.setName( readTextValue( cl ) ); | 166 | addressee.setName( readTextValue( cl ) ); |
167 | break; | 167 | break; |
168 | 168 | ||
169 | case EntityFullName: | 169 | case EntityFullName: |
170 | addressee.setFormattedName( readTextValue( cl ) ); | 170 | addressee.setFormattedName( readTextValue( cl ) ); |
171 | break; | 171 | break; |
172 | 172 | ||
173 | case EntityURL: | 173 | case EntityURL: |
174 | addressee.setUrl( KURL( readTextValue( cl ) ) ); | 174 | addressee.setUrl( KURL( readTextValue( cl ) ) ); |