summaryrefslogtreecommitdiffabout
path: root/kabc/formats
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/formats
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/formats') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/formats/binary/kabcformat_binaryE.pro2
-rw-r--r--kabc/formats/vcardformatplugin2.cpp20
2 files changed, 11 insertions, 11 deletions
diff --git a/kabc/formats/binary/kabcformat_binaryE.pro b/kabc/formats/binary/kabcformat_binaryE.pro
index 2d9594d..c71197e 100644
--- a/kabc/formats/binary/kabcformat_binaryE.pro
+++ b/kabc/formats/binary/kabcformat_binaryE.pro
@@ -1,21 +1,21 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5TARGET = microkabcformat_binary 5TARGET = microkabcformat_binary
6#INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat 6#INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat
7INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../qtcompat 7INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../qtcompat
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc 9MOC_DIR = moc
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += -lmicrokde -lmicrokabc 11LIBS += -lxmicrokde -lxmicrokabc
12LIBS += -L$(QPEDIR)/lib 12LIBS += -L$(QPEDIR)/lib
13DEFINES += KAB_EMBEDDED 13DEFINES += KAB_EMBEDDED
14 14
15INTERFACES = \ 15INTERFACES = \
16 16
17HEADERS = \ 17HEADERS = \
18 binaryformat.h 18 binaryformat.h
19 19
20SOURCES = \ 20SOURCES = \
21 binaryformat.cpp 21 binaryformat.cpp
diff --git a/kabc/formats/vcardformatplugin2.cpp b/kabc/formats/vcardformatplugin2.cpp
index 41b0c9a..fbebe92 100644
--- a/kabc/formats/vcardformatplugin2.cpp
+++ b/kabc/formats/vcardformatplugin2.cpp
@@ -1,124 +1,124 @@
1/* 1/*
2Enhanced Version of the file for platform independent KDE tools. 2Enhanced Version of the file for platform independent KDE tools.
3Copyright (c) 2004 Ulf Schenk 3Copyright (c) 2004 Ulf Schenk
4 4
5$Id$ 5$Id$
6*/ 6*/
7 7
8#include "vcardformatplugin2.h" 8#include "vcardformatplugin2.h"
9 9
10#include "address.h" 10#include "address.h"
11#include "addressee.h" 11#include "addressee.h"
12#include "vcardparser/vcardtool.h" 12#include "vcardparser/vcardtool.h"
13 13
14#include <qtextstream.h> 14#include <q3textstream.h>
15#include <qfile.h> 15#include <qfile.h>
16 16
17using namespace KABC; 17using namespace KABC;
18 18
19extern "C" 19extern "C"
20{ 20{
21 FormatPlugin *format() 21 FormatPlugin *format()
22 { 22 {
23 return new VCardFormatPlugin2(); 23 return new VCardFormatPlugin2();
24 } 24 }
25} 25}
26 26
27VCardFormatPlugin2::VCardFormatPlugin2() 27VCardFormatPlugin2::VCardFormatPlugin2()
28{ 28{
29} 29}
30 30
31VCardFormatPlugin2::~VCardFormatPlugin2() 31VCardFormatPlugin2::~VCardFormatPlugin2()
32{ 32{
33} 33}
34 34
35bool VCardFormatPlugin2::load( Addressee &addressee, QFile *file ) 35bool VCardFormatPlugin2::load( Addressee &addressee, QFile *file )
36{ 36{
37 qDebug("VCardFormatPlugin2::load"); 37 qDebug("VCardFormatPlugin2::load");
38 QString data; 38 QString data;
39 39
40 QTextStream t( file ); 40 Q3TextStream t( file );
41 t.setEncoding( QTextStream::UnicodeUTF8 ); 41 t.setEncoding( Q3TextStream::UnicodeUTF8 );
42 data = t.read(); 42 data = t.read();
43 43
44 VCardTool tool; 44 VCardTool tool;
45 45
46 Addressee::List l = tool.parseVCards( data ); 46 Addressee::List l = tool.parseVCards( data );
47 47
48 if ( ! l.first().isEmpty() ) { 48 if ( ! l.first().isEmpty() ) {
49 addressee = l.first(); 49 addressee = l.first();
50 return true; 50 return true;
51 } 51 }
52 52
53 return false; 53 return false;
54} 54}
55 55
56bool VCardFormatPlugin2::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 56bool VCardFormatPlugin2::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
57{ 57{
58 qDebug("VCardFormatPlugin2::loadAll"); 58 qDebug("VCardFormatPlugin2::loadAll");
59 QString data; 59 QString data;
60 60
61 QTextStream t( file ); 61 Q3TextStream t( file );
62 t.setEncoding( QTextStream::UnicodeUTF8 ); 62 t.setEncoding( Q3TextStream::UnicodeUTF8 );
63 data = t.read(); 63 data = t.read();
64 64
65 VCardTool tool; 65 VCardTool tool;
66 66
67 Addressee::List l = tool.parseVCards( data ); 67 Addressee::List l = tool.parseVCards( data );
68 68
69 Addressee::List::Iterator itr; 69 Addressee::List::Iterator itr;
70 70
71 for ( itr = l.begin(); itr != l.end(); ++itr) { 71 for ( itr = l.begin(); itr != l.end(); ++itr) {
72 Addressee addressee = *itr; 72 Addressee addressee = *itr;
73 addressee.setResource( resource ); 73 addressee.setResource( resource );
74 addressBook->insertAddressee( addressee ); 74 addressBook->insertAddressee( addressee );
75 } 75 }
76 76
77 return true; 77 return true;
78} 78}
79 79
80void VCardFormatPlugin2::save( const Addressee &addressee, QFile *file ) 80void VCardFormatPlugin2::save( const Addressee &addressee, QFile *file )
81{ 81{
82 qDebug("VCardFormatPlugin2::save"); 82 qDebug("VCardFormatPlugin2::save");
83 VCardTool tool; 83 VCardTool tool;
84 Addressee::List vcardlist; 84 Addressee::List vcardlist;
85 85
86 86
87 vcardlist.append( addressee ); 87 vcardlist.append( addressee );
88 88
89 QTextStream t( file ); 89 Q3TextStream t( file );
90 t.setEncoding( QTextStream::UnicodeUTF8 ); 90 t.setEncoding( Q3TextStream::UnicodeUTF8 );
91 t << tool.createVCards( vcardlist ); 91 t << tool.createVCards( vcardlist );
92} 92}
93 93
94void VCardFormatPlugin2::saveAll( AddressBook *ab, Resource *resource, QFile *file ) 94void VCardFormatPlugin2::saveAll( AddressBook *ab, Resource *resource, QFile *file )
95{ 95{
96 qDebug("VCardFormatPlugin2::saveAll"); 96 qDebug("VCardFormatPlugin2::saveAll");
97 VCardTool tool; 97 VCardTool tool;
98 Addressee::List vcardlist; 98 Addressee::List vcardlist;
99 99
100 AddressBook::Iterator it; 100 AddressBook::Iterator it;
101 for ( it = ab->begin(); it != ab->end(); ++it ) { 101 for ( it = ab->begin(); it != ab->end(); ++it ) {
102 if ( (*it).resource() == resource ) { 102 if ( (*it).resource() == resource ) {
103 (*it).setChanged( false ); 103 (*it).setChanged( false );
104 vcardlist.append( *it ); 104 vcardlist.append( *it );
105 } 105 }
106 } 106 }
107 107
108 QTextStream t( file ); 108 Q3TextStream t( file );
109 t.setEncoding( QTextStream::UnicodeUTF8 ); 109 t.setEncoding( Q3TextStream::UnicodeUTF8 );
110 t << tool.createVCards( vcardlist ); 110 t << tool.createVCards( vcardlist );
111} 111}
112 112
113bool VCardFormatPlugin2::checkFormat( QFile *file ) const 113bool VCardFormatPlugin2::checkFormat( QFile *file ) const
114{ 114{
115 QString line; 115 QString line;
116 116
117 file->readLine( line, 1024 ); 117 char tmp[1024]; file->readLine( tmp, 1024 ); line = tmp;
118 line = line.stripWhiteSpace(); 118 line = line.stripWhiteSpace();
119 if ( line == "BEGIN:VCARD" ) 119 if ( line == "BEGIN:VCARD" )
120 return true; 120 return true;
121 else 121 else
122 return false; 122 return false;
123} 123}
124 124