summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-06 16:20:25 (UTC)
committer zautrix <zautrix>2004-10-06 16:20:25 (UTC)
commit656636acfb8c607901c97c4f55129e29e1df9913 (patch) (unidiff)
tree25efd61a6b691822a11f43719efcbf69ce7d5c25
parenta22de800110d8350a5200a994b041e47d51bf4c6 (diff)
downloadkdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.zip
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.gz
kdepimpi-656636acfb8c607901c97c4f55129e29e1df9913.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp32
-rw-r--r--korganizer/mainwindow.cpp5
-rw-r--r--libkcal/libkcal.pro2
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/phoneformat.cpp117
-rw-r--r--libkcal/phoneformat.h1
6 files changed, 22 insertions, 137 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 185cf46..7bec90a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -18,13 +18,13 @@
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
@@ -36,12 +36,13 @@ $Id$
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qprogressbar.h> 41#include <qprogressbar.h>
42#include <libkdepim/phoneaccess.h>
42 43
43#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
44#include <qclipboard.h> 45#include <qclipboard.h>
45#include <qdir.h> 46#include <qdir.h>
46#include <qfile.h> 47#include <qfile.h>
47#include <qapplicaton.h> 48#include <qapplicaton.h>
@@ -670,27 +671,27 @@ void KABCore::export2phone()
670 return; 671 return;
671 } 672 }
672 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 673 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
673 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 674 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
674 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 675 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
675 676
676#if 0 677
677 PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 678 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
678 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 679 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
679 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 680 KPimGlobalPrefs::instance()->mEx2PhoneModel );
680 681
682 QStringList uids = mViewManager->selectedUids();
683 if ( uids.isEmpty() )
684 return;
681 685
686#ifdef _WIN32_
687 QString fileName = locateLocal("tmp", "tempfile.vcf");
688#else
689 QString fileName = "/tmp/kdepimtemp.vcf";
690#endif
682 691
683
684
685 QString fileName = "/tmp/kapibeamfile.vcf";
686
687
688 //QDir().mkdir( dirName, true );
689
690
691 KABC::VCardConverter converter; 692 KABC::VCardConverter converter;
692 QString description; 693 QString description;
693 QString datastream; 694 QString datastream;
694 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 695 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
695 KABC::Addressee a = mAddressBook->findByUid( *it ); 696 KABC::Addressee a = mAddressBook->findByUid( *it );
696 697
@@ -715,31 +716,26 @@ void KABCore::export2phone()
715 datastream +=vcard.mid( start, next - start); 716 datastream +=vcard.mid( start, next - start);
716 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 717 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
717 start = sep; 718 start = sep;
718 } 719 }
719 datastream += vcard.mid( start,vcard.length() ); 720 datastream += vcard.mid( start,vcard.length() );
720 } 721 }
721#ifndef DESKTOP_VERSION
722 QFile outFile(fileName); 722 QFile outFile(fileName);
723 if ( outFile.open(IO_WriteOnly) ) { 723 if ( outFile.open(IO_WriteOnly) ) {
724 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 724 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
725 QTextStream t( &outFile ); // use a text stream 725 QTextStream t( &outFile ); // use a text stream
726 t.setEncoding( QTextStream::UnicodeUTF8 ); 726 t.setEncoding( QTextStream::UnicodeUTF8 );
727 t <<datastream; 727 t <<datastream;
728 outFile.close(); 728 outFile.close();
729 Ir *ir = new Ir( this );
730 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
731 ir->send( fileName, description, "text/x-vCard" );
732 } else { 729 } else {
733 qDebug("Error open temp beam file "); 730 qDebug("Error open temp file ");
734 return; 731 return;
735 } 732 }
736#endif
737
738 733
739 734
735#if 0
740 736
741 setCaption( i18n("Writing to phone...")); 737 setCaption( i18n("Writing to phone..."));
742 if ( PhoneFormat::writeToPhone( cal ) ) 738 if ( PhoneFormat::writeToPhone( cal ) )
743 setCaption( i18n("Export to phone successful!")); 739 setCaption( i18n("Export to phone successful!"));
744 else 740 else
745 setCaption( i18n("Error exporting to phone!")); 741 setCaption( i18n("Error exporting to phone!"));
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2f286e0..ec69b11 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -36,12 +36,13 @@
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h>
42#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
43#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
44 45
45#include "calendarview.h" 46#include "calendarview.h"
46#include "koviewmanager.h" 47#include "koviewmanager.h"
47#include "datenavigator.h" 48#include "datenavigator.h"
@@ -1229,14 +1230,14 @@ void MainWindow::exportToPhone( int mode )
1229 if ( add ) { 1230 if ( add ) {
1230 Incidence *in = incidence->clone(); 1231 Incidence *in = incidence->clone();
1231 cal->addIncidence( in ); 1232 cal->addIncidence( in );
1232 } 1233 }
1233 } 1234 }
1234 incidence = delSel.next(); 1235 incidence = delSel.next();
1235 } 1236 }
1236 PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1237 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1237 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1238 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1238 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1239 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1239 1240
1240 setCaption( i18n("Writing to phone...")); 1241 setCaption( i18n("Writing to phone..."));
1241 if ( PhoneFormat::writeToPhone( cal ) ) 1242 if ( PhoneFormat::writeToPhone( cal ) )
1242 setCaption( i18n("Export to phone successful!")); 1243 setCaption( i18n("Export to phone successful!"));
diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro
index 7a0bd22..171c726 100644
--- a/libkcal/libkcal.pro
+++ b/libkcal/libkcal.pro
@@ -1,13 +1,13 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = microkcal
4 4
5include( ../variables.pri ) 5include( ../variables.pri )
6 6
7INCLUDEPATH += ../microkde versit ../microkde/kdecore 7INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore
8#../qtcompat 8#../qtcompat
9INCLUDEPATH += ../libical/src/libical 9INCLUDEPATH += ../libical/src/libical
10INCLUDEPATH += ../libical/src/libicalss 10INCLUDEPATH += ../libical/src/libicalss
11DESTDIR = ../bin 11DESTDIR = ../bin
12DEFINES += DESKTOP_VERSION 12DEFINES += DESKTOP_VERSION
13unix: { 13unix: {
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index e379b95..e42dc9c 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,11 +1,11 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = komicrokcal 3 TARGET = komicrokcal
4 4
5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include 5INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include
6INCLUDEPATH += ../libical/src/libical 6INCLUDEPATH += ../libical/src/libical
7INCLUDEPATH += ../libical/src/libicalss 7INCLUDEPATH += ../libical/src/libicalss
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += ../libical/lib/$(PLATFORM)/libical.a 11LIBS += ../libical/lib/$(PLATFORM)/libical.a
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index b2a62b1..c39413e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -33,12 +33,13 @@
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <phoneaccess.h>
39 40
40#include "calendar.h" 41#include "calendar.h"
41#include "alarm.h" 42#include "alarm.h"
42#include "recurrence.h" 43#include "recurrence.h"
43#include "calendarlocal.h" 44#include "calendarlocal.h"
44 45
@@ -81,117 +82,19 @@ public:
81 82
82 83
83 84
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 85PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 86{
86 mProfileName = profileName; 87 mProfileName = profileName;
87 writeConfig( device, connection, model ); 88 PhoneAccess::writeConfig( device, connection, model );
88} 89}
89 90
90PhoneFormat::~PhoneFormat() 91PhoneFormat::~PhoneFormat()
91{ 92{
92} 93}
93void PhoneFormat::writeConfig( QString device, QString connection, QString model )
94{
95#ifdef _WIN32_
96 QString fileName = qApp->applicationDirPath () +"\\gammurc";
97#else
98 QString fileName = QDir::homeDirPath() +"/.gammurc";
99#endif
100 //qDebug("save %d ", load );
101 QString content;
102 bool write = false;
103 bool addPort = true, addConnection = true, addModel = true;
104 QFile file( fileName );
105 if ( QFile::exists( fileName) ) {
106 if (!file.open( IO_ReadOnly ) ) {
107 qDebug("Error: cannot open %s ", fileName.latin1() );
108 return;
109 }
110 QString line;
111 while ( file.readLine( line, 1024 ) > 0 ) {
112 //qDebug("*%s* ", line.latin1() );
113 if ( line.left(7 ) == "[gammu]" ) {
114 ;
115 } else
116 if ( line.left(4 ) == "port" ) {
117 if ( line == "port = " + device+"\n" ) {
118 content += line ;
119 addPort = false;
120 //qDebug("port found" );
121 }
122
123 } else if ( line.left(5 ) == "model" ) {
124 if ( line == "model = " + model +"\n") {
125 content += line ;
126 addModel = false;
127 //qDebug("model found" );
128 }
129
130 } else if ( line.left( 10 ) == "connection" ) {
131 if ( line == "connection = " + connection +"\n") {
132 addConnection = false;
133 content += line ;
134 //qDebug("con found" );
135 }
136
137 } else {
138 content += line ;
139 }
140 }
141 file.close();
142 } else {
143 if ( ! connection.isEmpty() ) {
144 addConnection = true;
145 }
146 if ( ! device.isEmpty() ) {
147 addPort = true;
148 94
149 }
150 if ( ! model.isEmpty() ) {
151 addModel = true;
152 }
153 }
154
155 if ( addConnection ) {
156 if ( ! write )
157 content += "[gammu]\n";
158 write = true;
159 content += "connection = ";
160 content += connection;
161 content += "\n";
162 }
163 if ( addPort ) {
164 if ( ! write )
165 content += "[gammu]\n";
166 write = true;
167 content += "port = ";
168 content += device;
169 content += "\n";
170
171 }
172 if ( addModel ) {
173 if ( ! write )
174 content += "[gammu]\n";
175 write = true;
176 content += "model = ";
177 content += model;
178 content += "\n";
179 }
180 if ( write ) {
181 if (!file.open( IO_WriteOnly ) ) {
182 qDebug("Error: cannot write file %s ", fileName.latin1() );
183 return;
184 }
185 qDebug("Writing file %s ", fileName.latin1() );
186 QTextStream ts( &file );
187 ts << content ;
188 file.close();
189 }
190
191}
192#if 0 95#if 0
193int PhoneFormat::initDevice(GSM_StateMachine *s) 96int PhoneFormat::initDevice(GSM_StateMachine *s)
194{ 97{
195 GSM_ReadConfig(NULL, &s->Config[0], 0); 98 GSM_ReadConfig(NULL, &s->Config[0], 0);
196 s->ConfigNum = 1; 99 s->ConfigNum = 1;
197 GSM_Config *cfg = &s->Config[0]; 100 GSM_Config *cfg = &s->Config[0];
@@ -587,27 +490,13 @@ bool PhoneFormat::writeToPhone( Calendar * calendar)
587#endif 490#endif
588 491
589 VCalFormat vfsave; 492 VCalFormat vfsave;
590 vfsave.setLocalTime ( true ); 493 vfsave.setLocalTime ( true );
591 if ( ! vfsave.save( calendar, fileName ) ) 494 if ( ! vfsave.save( calendar, fileName ) )
592 return false; 495 return false;
593 // 4 call kammu 496 return PhoneAccess::writeToPhone( fileName );
594#ifdef DESKTOP_VERSION
595 QString command ="./kammu --restore " + fileName ;
596#else
597 QString command ="kammu --restore " + fileName ;
598#endif
599 int ret;
600 while ( (ret = system ( command.latin1())) != 0 ) {
601 qDebug("Error S::command returned %d. asking users", ret);
602 int retval = KMessageBox::warningContinueCancel(0,
603 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
604 if ( retval != KMessageBox::Continue )
605 return false;
606 }
607 return true;
608} 497}
609bool PhoneFormat::save( Calendar *calendar) 498bool PhoneFormat::save( Calendar *calendar)
610{ 499{
611 QLabel status ( i18n(" Opening device ..."), 0 ); 500 QLabel status ( i18n(" Opening device ..."), 0 );
612 int w = status.sizeHint().width()+20 ; 501 int w = status.sizeHint().width()+20 ;
613 if ( w < 200 ) w = 230; 502 if ( w < 200 ) w = 230;
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 61e8160..001fd81 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -45,13 +45,12 @@ class PhoneFormat : public QObject {
45 bool save( Calendar * ); 45 bool save( Calendar * );
46 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
47 QString toString( Calendar * ); 47 QString toString( Calendar * );
48 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
49 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
50 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
51 static void writeConfig( QString device,QString connection, QString model );
52 static bool writeToPhone( Calendar * ); 51 static bool writeToPhone( Calendar * );
53 private: 52 private:
54 void copyEvent( Event* to, Event* from ); 53 void copyEvent( Event* to, Event* from );
55 void copyTodo( Todo* to, Todo* from ); 54 void copyTodo( Todo* to, Todo* from );
56 //int initDevice(GSM_StateMachine *s); 55 //int initDevice(GSM_StateMachine *s);
57 QString mProfileName; 56 QString mProfileName;