/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/org/waxworlds/edam/importcontacts/VcardImporter.java

  • Committer: edam
  • Date: 2011-05-30 14:04:51 UTC
  • Revision ID: edam@waxworlds.org-20110530140451-d99fy3zoi6zq1jf2
- renamed VCFImporter to VcardImporter and VCard to Vcard

Show diffs side-by-side

added added

removed removed

213
213
                                // look for vcard content or ending
214
214
                                if( line.matches( "^END:VCARD" ) )
215
215
                                {
216
 
                                        // finalise the vcard/contact
 
216
                                        // store vcard and do away with it
217
217
                                        try {
218
 
                                                vcard.finaliseVcard();
 
218
                                                vcard.finaliseParsing();
 
219
                                                importContact( vcard );
219
220
                                        }
220
221
                                        catch( Vcard.ParseException e ) {
221
222
                                                skipContact();
226
227
                                                        finish( ACTION_ABORT );
227
228
                                                }
228
229
                                        }
229
 
 
230
 
                                        // pass the finalised contact to the importer
231
 
                                        importContact( vcard );
232
 
 
233
 
                                        // and discard it
 
230
                                        catch( Vcard.SkipContactException e ) {
 
231
                                                skipContact();
 
232
                                                // do nothing
 
233
                                        }
234
234
                                        vcard = null;
235
235
                                }
236
236
                                else
254
254
                                                // get to another BEGIN:VCARD line.
255
255
                                                vcard = null;
256
256
                                        }
257
 
                                        catch( Vcard.SkipImportException e ) {
 
257
                                        catch( Vcard.SkipContactException e ) {
258
258
                                                skipContact();
259
259
                                                // abort this vCard. Further lines will be ignored until
260
260
                                                // we get to another BEGIN:VCARD line.
387
387
                }
388
388
 
389
389
                @SuppressWarnings("serial")
390
 
                protected class SkipImportException extends Exception { }
 
390
                protected class SkipContactException extends Exception { }
391
391
 
392
392
                private String extractCollonPartFromLine( ByteBuffer buffer,
393
393
                        String line, boolean former )
429
429
 
430
430
                public void parseLine( ByteBuffer buffer, String line,
431
431
                        boolean next_line_looks_folded )
432
 
                        throws ParseException, SkipImportException,
 
432
                        throws ParseException, SkipContactException,
433
433
                        AbortImportException
434
434
                {
435
435
                        // do we have a version yet?
834
834
                        addAddress( value, type );
835
835
                }
836
836
 
837
 
                public void finaliseVcard()
838
 
                        throws ParseException
 
837
                public void finaliseParsing()
 
838
                        throws ParseException, SkipContactException,
 
839
                        AbortImportException
839
840
                {
840
841
                        // missing version (and data is present)
841
842
                        if( _version == null && _buffers != null )
842
843
                                throw new ParseException( R.string.error_vcf_malformed );
843
844
 
844
 
                        // finalise the parent class
 
845
                        // check if we should import this contact
845
846
                        try {
846
 
                                finalise();
 
847
                                if( !isImportRequired( this ) )
 
848
                                        throw new SkipContactException();
847
849
                        }
848
 
                        catch( ContactNotIdentifiableException e ) {
 
850
                        catch( ContactNeedsMoreInfoException e ) {
849
851
                                throw new ParseException( R.string.error_vcf_notenoughinfo );
850
852
                        }
851
853
                }