summaryrefslogtreecommitdiffabout
path: root/kde2file
Unidiff
Diffstat (limited to 'kde2file') (more/less context) (ignore whitespace changes)
-rw-r--r--kde2file/abdump/main.cpp3
-rw-r--r--kde2file/caldump/main.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp
index b359cfe..824d054 100644
--- a/kde2file/abdump/main.cpp
+++ b/kde2file/abdump/main.cpp
@@ -57,97 +57,98 @@ static KCmdLineOptions options[] =
57 { "dump", 57 { "dump",
58 I18N_NOOP( "Dumps addressbook" ), 0 }, 58 I18N_NOOP( "Dumps addressbook" ), 0 },
59 { "read", 59 { "read",
60 I18N_NOOP( "Reads addressbook" ), 0 }, 60 I18N_NOOP( "Reads addressbook" ), 0 },
61 KCmdLineLastOption 61 KCmdLineLastOption
62 }; 62 };
63 63
64int main( int argc, char *argv[] ) 64int main( int argc, char *argv[] )
65{ 65{
66 KAboutData aboutData( 66 KAboutData aboutData(
67 progName, // internal program name 67 progName, // internal program name
68 I18N_NOOP( progDisplay ), // displayable program name. 68 I18N_NOOP( progDisplay ), // displayable program name.
69 progVersion, // version string 69 progVersion, // version string
70 I18N_NOOP( progDesc ), // short porgram description 70 I18N_NOOP( progDesc ), // short porgram description
71 KAboutData::License_GPL, // license type 71 KAboutData::License_GPL, // license type
72 "(c) 2004, Lutz Rogowski", // copyright statement 72 "(c) 2004, Lutz Rogowski", // copyright statement
73 0, // any free form text 73 0, // any free form text
74 "", // program home page address 74 "", // program home page address
75 "bugs.kde.org" // bug report email address 75 "bugs.kde.org" // bug report email address
76 ); 76 );
77 77
78 78
79 // KCmdLineArgs::init() final 'true' argument indicates no commandline options 79 // KCmdLineArgs::init() final 'true' argument indicates no commandline options
80 // for QApplication/KApplication (no KDE or Qt options) 80 // for QApplication/KApplication (no KDE or Qt options)
81 KCmdLineArgs::init( argc, argv, &aboutData, true ); 81 KCmdLineArgs::init( argc, argv, &aboutData, true );
82 KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. 82 KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
83 83
84 KInstance ins ( progName ); 84 KInstance ins ( progName );
85 85
86 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 86 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
87 87
88 bool read = false; 88 bool read = false;
89 if ( args->isSet( "read" ) ) { 89 if ( args->isSet( "read" ) ) {
90 read = true; 90 read = true;
91 qDebug("read "); 91 qDebug("read ");
92 } 92 }
93 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 93 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
94 94
95 KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self(); 95 KABC::StdAddressBook* standardAddressBook = KABC::StdAddressBook::self();
96 standardAddressBook->setAutomaticSave( false ); 96 standardAddressBook->setAutomaticSave( false );
97 qDebug("************************************* "); 97 qDebug("************************************* ");
98 qDebug("***************kdeABdump************* "); 98 qDebug("***************kdeABdump************* ");
99 qDebug("************************************* "); 99 qDebug("************************************* ");
100 if ( !read ) { 100 if ( !read ) {
101 KABC::AddressBook::Iterator it; 101 KABC::AddressBook::Iterator it;
102 KABC::VCardConverter converter; 102 KABC::VCardConverter converter;
103 QString datastream; 103 QString datastream;
104 for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) { 104 for( it = standardAddressBook->begin(); it != standardAddressBook->end(); ++it ) {
105 if ( (*it).isEmpty() || ! (*it).resource() ) 105 // if ( (*it).isEmpty() || ! (*it).resource() )
106 if ( (*it).isEmpty() )
106 continue; 107 continue;
107 KABC::Addressee a = ( *it ); 108 KABC::Addressee a = ( *it );
108 QString vcard = converter.createVCard( a ); 109 QString vcard = converter.createVCard( a );
109 vcard += QString("\r\n"); 110 vcard += QString("\r\n");
110 datastream += vcard; 111 datastream += vcard;
111 } 112 }
112 QFile outFile(fileName); 113 QFile outFile(fileName);
113 if ( outFile.open(IO_WriteOnly) ) { 114 if ( outFile.open(IO_WriteOnly) ) {
114 QTextStream t( &outFile ); // use a text stream 115 QTextStream t( &outFile ); // use a text stream
115 t.setEncoding( QTextStream::UnicodeUTF8 ); 116 t.setEncoding( QTextStream::UnicodeUTF8 );
116 t <<datastream; 117 t <<datastream;
117 t << "\r\n\r\n"; 118 t << "\r\n\r\n";
118 outFile.close(); 119 outFile.close();
119 } 120 }
120 } else { 121 } else {
121 //Addressee::List aList;//parseVCards( const QString& vcard ); 122 //Addressee::List aList;//parseVCards( const QString& vcard );
122 KABC::Addressee::List list; 123 KABC::Addressee::List list;
123 int added = 0, changedC = 0, deleted = 0; 124 int added = 0, changedC = 0, deleted = 0;
124 QFile file( fileName ); 125 QFile file( fileName );
125 if ( file.open( IO_ReadOnly ) ) { 126 if ( file.open( IO_ReadOnly ) ) {
126 QTextStream t( &file ); // use a text stream 127 QTextStream t( &file ); // use a text stream
127 t.setEncoding( QTextStream::UnicodeUTF8 ); 128 t.setEncoding( QTextStream::UnicodeUTF8 );
128 QString data; 129 QString data;
129 data = t.read(); 130 data = t.read();
130 file.close(); 131 file.close();
131 KABC::VCardConverter converter; 132 KABC::VCardConverter converter;
132 list = converter.parseVCards( data ); 133 list = converter.parseVCards( data );
133 qDebug("kdeABdump::file has %d entries", list.count()); 134 qDebug("kdeABdump::file has %d entries", list.count());
134 135
135 KABC::Addressee::List::Iterator it; 136 KABC::Addressee::List::Iterator it;
136 for ( it = list.begin();it != list.end();++it) { 137 for ( it = list.begin();it != list.end();++it) {
137 (*it).setChanged( true ); 138 (*it).setChanged( true );
138 bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed"); 139 bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed");
139 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 140 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
140 //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1()); 141 //qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1());
141 if ( changed ) { 142 if ( changed ) {
142 //qDebug("changed Addressee found! "); 143 //qDebug("changed Addressee found! ");
143 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); 144 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
144 if ( ! std.isEmpty() ) 145 if ( ! std.isEmpty() )
145 (*it).setResource(std.resource()); 146 (*it).setResource(std.resource());
146 standardAddressBook->insertAddressee( (*it) ); 147 standardAddressBook->insertAddressee( (*it) );
147 ++changedC; 148 ++changedC;
148 } else { 149 } else {
149 //maybe added? 150 //maybe added?
150 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() ); 151 KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
151 if ( std.isEmpty() ) { 152 if ( std.isEmpty() ) {
152 standardAddressBook->insertAddressee( (*it) ); 153 standardAddressBook->insertAddressee( (*it) );
153 ++added; 154 ++added;
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp
index 9cc1a73..c8755cd 100644
--- a/kde2file/caldump/main.cpp
+++ b/kde2file/caldump/main.cpp
@@ -84,97 +84,98 @@ int main( int argc, char *argv[] )
84 progName, // internal program name 84 progName, // internal program name
85 I18N_NOOP( progDisplay ), // displayable program name. 85 I18N_NOOP( progDisplay ), // displayable program name.
86 progVersion, // version string 86 progVersion, // version string
87 I18N_NOOP( progDesc ), // short porgram description 87 I18N_NOOP( progDesc ), // short porgram description
88 KAboutData::License_GPL, // license type 88 KAboutData::License_GPL, // license type
89 "(c) 2004, Lutz Rogowski", // copyright statement 89 "(c) 2004, Lutz Rogowski", // copyright statement
90 0, // any free form text 90 0, // any free form text
91 "", // program home page address 91 "", // program home page address
92 "bugs.kde.org" // bug report email address 92 "bugs.kde.org" // bug report email address
93 ); 93 );
94 94
95 95
96 // KCmdLineArgs::init() final 'true' argument indicates no commandline options 96 // KCmdLineArgs::init() final 'true' argument indicates no commandline options
97 // for QApplication/KApplication (no KDE or Qt options) 97 // for QApplication/KApplication (no KDE or Qt options)
98 KCmdLineArgs::init( argc, argv, &aboutData, true ); 98 KCmdLineArgs::init( argc, argv, &aboutData, true );
99 KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. 99 KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
100 100
101 KInstance ins ( progName ); 101 KInstance ins ( progName );
102 102
103 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 103 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
104 104
105 bool read = false; 105 bool read = false;
106 if ( args->isSet( "read" ) ) { 106 if ( args->isSet( "read" ) ) {
107 read = true; 107 read = true;
108 qDebug("read "); 108 qDebug("read ");
109 } 109 }
110 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 110 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
111 CalendarResources *calendarResource = 0; 111 CalendarResources *calendarResource = 0;
112 CalendarLocal *localCalendar = 0; 112 CalendarLocal *localCalendar = 0;
113 KConfig c( locate( "config", "korganizerrc" ) ); 113 KConfig c( locate( "config", "korganizerrc" ) );
114 c.setGroup( "Time & Date" ); 114 c.setGroup( "Time & Date" );
115 QString tz = c.readEntry( "TimeZoneId" ); 115 QString tz = c.readEntry( "TimeZoneId" );
116 calendarResource = new CalendarResources( tz ); 116 calendarResource = new CalendarResources( tz );
117 calendarResource->readConfig(); 117 calendarResource->readConfig();
118 calendarResource->load(); 118 calendarResource->load();
119 qDebug("************************************* "); 119 qDebug("************************************* ");
120 qDebug("**************kdecaldump************* "); 120 qDebug("**************kdecaldump************* ");
121 qDebug("************************************* "); 121 qDebug("************************************* ");
122 qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); 122 qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1());
123 123
124 if ( !read ) { 124 if ( !read ) {
125 localCalendar = new CalendarLocal(); 125 localCalendar = new CalendarLocal();
126 localCalendar->setTimeZoneId( calendarResource->timeZoneId()); 126 localCalendar->setTimeZoneId( calendarResource->timeZoneId());
127 KCal::Incidence::List allInc = calendarResource->rawIncidences(); 127 KCal::Incidence::List allInc = calendarResource->rawIncidences();
128 Incidence::List::ConstIterator it; 128 Incidence::List::ConstIterator it;
129 int num = 0; 129 int num = 0;
130 for( it = allInc.begin(); it != allInc.end(); ++it ) { 130 for( it = allInc.begin(); it != allInc.end(); ++it ) {
131 ResourceCalendar * re = calendarResource->resource( (*it) ); 131 ResourceCalendar * re = calendarResource->resource( (*it) );
132 if ( re ) { 132 //if ( re )
133 {
133 ++num; 134 ++num;
134 Incidence* cl = (*it)->clone(); 135 Incidence* cl = (*it)->clone();
135 cl->setLastModified( (*it)->lastModified() ); 136 cl->setLastModified( (*it)->lastModified() );
136 if ( cl->type() == "Journal" ) 137 if ( cl->type() == "Journal" )
137 localCalendar->addJournal( (Journal *) cl ); 138 localCalendar->addJournal( (Journal *) cl );
138 else if ( cl->type() == "Todo" ) 139 else if ( cl->type() == "Todo" )
139 localCalendar->addTodo( (Todo *) cl ); 140 localCalendar->addTodo( (Todo *) cl );
140 else if ( cl->type() == "Event" ) 141 else if ( cl->type() == "Event" )
141 localCalendar->addEvent( (Event *) cl ); 142 localCalendar->addEvent( (Event *) cl );
142 } 143 }
143 } 144 }
144 145
145 FileStorage* storage = new FileStorage( calendarResource ); 146 FileStorage* storage = new FileStorage( calendarResource );
146 storage->setFileName( fileName ); 147 storage->setFileName( fileName );
147 storage->setSaveFormat( new ICalFormat() ); 148 storage->setSaveFormat( new ICalFormat() );
148 storage->save(); 149 storage->save();
149 delete storage; 150 delete storage;
150 qDebug("************************************* "); 151 qDebug("************************************* ");
151 qDebug("************kdecaldump*************** "); 152 qDebug("************kdecaldump*************** ");
152 qDebug("************************************* "); 153 qDebug("************************************* ");
153 qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); 154 qDebug("%d calendar entries dumped to file %s", num, fileName.latin1());
154 155
155 } else { 156 } else {
156 qDebug("************load"); 157 qDebug("************load");
157 localCalendar = new CalendarLocal(); 158 localCalendar = new CalendarLocal();
158 localCalendar->setTimeZoneId( calendarResource->timeZoneId()); 159 localCalendar->setTimeZoneId( calendarResource->timeZoneId());
159 FileStorage* storage = new FileStorage( localCalendar ); 160 FileStorage* storage = new FileStorage( localCalendar );
160 storage->setFileName( fileName ); 161 storage->setFileName( fileName );
161 int num = 0; 162 int num = 0;
162 int del = 0; 163 int del = 0;
163 int add = 0; 164 int add = 0;
164 if ( storage->load() ) { 165 if ( storage->load() ) {
165 qDebug("***********loaded!"); 166 qDebug("***********loaded!");
166 KCal::Incidence::List newInc = localCalendar->rawIncidences(); 167 KCal::Incidence::List newInc = localCalendar->rawIncidences();
167 Incidence::List::ConstIterator it; 168 Incidence::List::ConstIterator it;
168 for( it = newInc.begin(); it != newInc.end(); ++it ) { 169 for( it = newInc.begin(); it != newInc.end(); ++it ) {
169 if ( (*it)->pilotId() > 1 ) { //changed 170 if ( (*it)->pilotId() > 1 ) { //changed
170 qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); 171 qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1());
171 Incidence *incOld = calendarResource->incidence( (*it)->uid() ); 172 Incidence *incOld = calendarResource->incidence( (*it)->uid() );
172 ResourceCalendar * res = 0; 173 ResourceCalendar * res = 0;
173 if ( incOld ) 174 if ( incOld )
174 res = calendarResource->resource( incOld ); 175 res = calendarResource->resource( incOld );
175 if ( res ) { 176 if ( res ) {
176 Incidence* cl = (*it)->clone(); 177 Incidence* cl = (*it)->clone();
177 cl->setPilotId( incOld->pilotId() ); 178 cl->setPilotId( incOld->pilotId() );
178 ++num; 179 ++num;
179 if ( incOld->type() == "Journal" ) 180 if ( incOld->type() == "Journal" )
180 calendarResource->deleteJournal( (Journal *) incOld ); 181 calendarResource->deleteJournal( (Journal *) incOld );